rubenada commented on code in PR #6523:
URL: https://github.com/apache/hive/pull/6523#discussion_r3612819429
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/type/HiveFunctionHelper.java:
##########
@@ -336,6 +336,19 @@ public RexNode getExpression(String functionText,
FunctionInfo fi,
RexUtil.flatten(call.getOperands(), call.getOperator()));
}
+ // Avoid creating incorrect expressions like $1 < NULL or $1 = NULL or
NULL = NULL
+ // which may be problematic for Calcite later on
+ if (expr.isA(SqlKind.BINARY_COMPARISON) && expr.getKind() !=
SqlKind.IS_DISTINCT_FROM
+ && expr.getKind() != SqlKind.IS_NOT_DISTINCT_FROM) {
+ RexCall call = (RexCall) expr;
+ RexNode op0 = call.getOperands().get(0);
+ RexNode op1 = call.getOperands().get(1);
+ if ((op0.getKind() == SqlKind.LITERAL && ((RexLiteral) op0).isNull()) ||
+ (op1.getKind() == SqlKind.LITERAL && ((RexLiteral) op1).isNull())) {
+ expr = rexBuilder.makeNullLiteral(expr.getType());
+ }
+ }
+
Review Comment:
Refactored to do the check via `RexSimplify#simplifyComparisonWithNull`
--
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]