soumyakanti3578 commented on code in PR #6550:
URL: https://github.com/apache/hive/pull/6550#discussion_r3469172229
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/type/HiveFunctionHelper.java:
##########
@@ -135,12 +136,20 @@ public RelDataType getReturnType(FunctionInfo fi,
List<RexNode> inputs)
inputsOIs[i] = createObjectInspector(inputs.get(i));
}
// 2) Initialize and obtain return type
- ObjectInspector oi = fi.getGenericUDF() != null ?
- fi.getGenericUDF().initializeAndFoldConstants(inputsOIs) :
+ GenericUDF genericUDF = fi.getGenericUDF();
+ ObjectInspector oi = genericUDF != null ?
+ genericUDF.initializeAndFoldConstants(inputsOIs) :
fi.getGenericUDTF().initialize(inputsOIs);
// 3) Convert to RelDataType
- return TypeConverter.convert(
+ RelDataType returnType = TypeConverter.convert(
TypeInfoUtils.getTypeInfoFromObjectInspector(oi),
rexBuilder.getTypeFactory());
+ // Hive has no concept of non-nullable types, but some UDFs (e.g. IS NULL)
always return
+ // non-nullable BOOLEAN, which Calcite's RexSimplify asserts via
validateStrongPolicy.
+ if (genericUDF instanceof NonNullableReturnTypeUDF) {
+ returnType =
rexBuilder.getTypeFactory().createTypeWithNullability(returnType, false);
+ }
Review Comment:
Done! 👍🏼
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]