t3rmin4t0r commented on a change in pull request #656: HIVE-21742 :
Vectorization: CASE result type casting
URL: https://github.com/apache/hive/pull/656#discussion_r289582420
##########
File path:
ql/src/java/org/apache/hadoop/hive/ql/parse/TypeCheckProcFactory.java
##########
@@ -1274,6 +1274,40 @@ protected ExprNodeDesc
getXpathOrFuncExprNodeDesc(ASTNode expr,
children);
}
+ // introduce cast for expressions which are of different type than
parent WHEN expr's type
+ // this is done so that vectorization is able to vectorize
appropriately
+ if (genericUDF instanceof GenericUDFWhen && desc instanceof
ExprNodeGenericFuncDesc) {
+ String castTypeName = desc.getTypeInfo().getTypeName();
+ if (desc.getTypeInfo() instanceof DecimalTypeInfo) {
+ castTypeName = serdeConstants.DECIMAL_TYPE_NAME;
+ }
+ FunctionInfo castFun =
FunctionRegistry.getFunctionInfo(castTypeName);
+
+ String whenTypeName = desc.getTypeInfo().getTypeName();
+ List<ExprNodeDesc> updatedChildren = new ArrayList<>();
+ if (castFun != null) {
+ GenericUDF castUDF = castFun.getGenericUDF();
+ if (desc.getTypeInfo() instanceof DecimalTypeInfo || desc
+ .getTypeInfo() instanceof VarcharTypeInfo || desc
+ .getTypeInfo() instanceof CharTypeInfo || desc
+ .getTypeInfo() instanceof TimestampLocalTZTypeInfo) {
+ ((SettableUDF) castUDF).setTypeInfo(desc.getTypeInfo());
Review comment:
Special case for varchar(1) -> varchar(2) ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]