String astKeyName = astExprNodePair.getKey().toString().toLowerCase();
if (astExprNodePair.getKey().getType() == HiveParser.Identifier) {
astKeyName = stripIdentifierQuotes(astKeyName);
}
String colType = partCols.get(astKeyName);
ObjectInspector inputOI = astExprNodePair.getValue().getWritableObjectInspector();
TypeInfo expectedType =
TypeInfoUtils.getTypeInfoFromTypeString(colType);
ObjectInspector outputOI =
TypeInfoUtils.getStandardWritableObjectInspectorFromTypeInfo(expectedType);
Object value = null;
try {
value =
ExprNodeEvaluatorFactory.get(astExprNodePair.getValue()).
evaluate(partSpec.get(astKeyName));
} catch (HiveException e) {
throw new SemanticException(e);
}
Object convertedValue =
ObjectInspectorConverters.getConverter(inputOI, outputOI).convert(value);
if (convertedValue == null) {
throw new SemanticException(ErrorMsg.PARTITION_SPEC_TYPE_MISMATCH.format(astKeyName,
inputOI.getTypeName(), outputOI.getTypeName()));
}
}
}
}