@Override /** * Return string representation of constant expression * Beside ExplainPlan task Default constraint also make use it to deserialize constant expression * to store it in metastore, which is later reparsed to generate appropriate constant expression * Therefore it is necessary for this method to qualify the intervals with appropriate qualifiers */ public String getExprString() { if (typeInfo.getCategory() == Category.PRIMITIVE) { return getFormatted(typeInfo, value); } else if (typeInfo.getCategory() == Category.STRUCT) { StringBuilder sb = new StringBuilder(); sb.append("const struct("); List<?> items = (List<?>) getWritableObjectInspector().getWritableConstantValue(); List<TypeInfo> structTypes = ((StructTypeInfo) typeInfo).getAllStructFieldTypeInfos(); for (int i = 0; i < structTypes.size(); i++) { final Object o = (i < items.size()) ? items.get(i) : null; sb.append(getFormatted(structTypes.get(i), o)).append(","); } sb.setCharAt(sb.length() - 1, ')'); return sb.toString(); } else { // unknown type return toString(); } }
@Override public String getExprString() { if (typeInfo.getCategory() == Category.PRIMITIVE) { return getFormatted(typeInfo, value); } else if (typeInfo.getCategory() == Category.STRUCT) { StringBuilder sb = new StringBuilder(); sb.append("const struct("); List<?> items = (List<?>) getWritableObjectInspector().getWritableConstantValue(); List<TypeInfo> structTypes = ((StructTypeInfo) typeInfo).getAllStructFieldTypeInfos(); for (int i = 0; i < structTypes.size(); i++) { final Object o = (i < items.size()) ? items.get(i) : null; sb.append(getFormatted(structTypes.get(i), o)).append(","); } sb.setCharAt(sb.length() - 1, ')'); return sb.toString(); } else { // unknown type return toString(); } }