sanel commented on a change in pull request #2080:
URL: https://github.com/apache/drill/pull/2080#discussion_r429652900
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/expr/ExpressionTreeMaterializer.java
##########
@@ -465,32 +465,43 @@ private LogicalExpression bindDrillFunc(FunctionCall call,
for (int i = 0; i < call.argCount(); ++i) {
LogicalExpression currentArg = call.arg(i);
- TypeProtos.MajorType parmType = matchedFuncHolder.getParamMajorType(i);
+ TypeProtos.MajorType paramType =
matchedFuncHolder.getParamMajorType(i);
// Case 1: If 1) the argument is NullExpression
// 2) the minor type of parameter of matchedFuncHolder is
not LATE
// (the type of null expression is still unknown)
// 3) the parameter of matchedFuncHolder allows null
input, or func's null_handling
// is NULL_IF_NULL (means null and non-null are
exchangeable).
// then replace NullExpression with a TypedNullConstant
- if (currentArg.equals(NullExpression.INSTANCE) &&
!MinorType.LATE.equals(parmType.getMinorType()) &&
- (TypeProtos.DataMode.OPTIONAL.equals(parmType.getMode()) ||
+ if (currentArg.equals(NullExpression.INSTANCE) &&
!MinorType.LATE.equals(paramType.getMinorType()) &&
+ (TypeProtos.DataMode.OPTIONAL.equals(paramType.getMode()) ||
matchedFuncHolder.getNullHandling() ==
FunctionTemplate.NullHandling.NULL_IF_NULL)) {
// Case 1: argument is a null expression, convert it to a typed null
- argsWithCast.add(new TypedNullConstant(parmType));
- } else if (Types.softEquals(parmType, currentArg.getMajorType(),
+ argsWithCast.add(new TypedNullConstant(paramType));
+ } else if (Types.softEquals(paramType, currentArg.getMajorType(),
matchedFuncHolder.getNullHandling() ==
FunctionTemplate.NullHandling.NULL_IF_NULL) ||
matchedFuncHolder.isFieldReader(i)) {
+ if (paramType.getMode() == DataMode.OPTIONAL
Review comment:
This could be refactored to separate function. Same construct down below.
----------------------------------------------------------------
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]