rubenada commented on code in PR #6495:
URL: https://github.com/apache/hive/pull/6495#discussion_r3267169790
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/translator/RexNodeConverter.java:
##########
@@ -577,6 +570,37 @@ public static List<RexNode>
transformInToOrOperands(List<RexNode> operands, RexB
return disjuncts;
}
+ /**
+ * This method tries to rewrite IN expression arguments into an equivalent
call.
+ * If there are only two elements, generates an EQUALS:
+ * IN [A,B] => EQUALS [A,B]
+ * Otherwise, tries to generate a SEARCH:
+ * IN [A,B,C] => SEARCH(A, SARG([B..B], [C..C]))
+ * If this is not possible (e.g., argument types not sufficiently compatible
to generate a Calcite SEARCH expression),
+ * tries to generate an OR expression:
+ * IN [A,B,C] => OR [EQUALS [A,B], EQUALS [A,C]]
+ * If this is not possible (e.g., non-deterministic calls are found in the
expressions), returns null
+ */
+ public static RexNode rewriteInClause(List<RexNode> childRexNodeLst,
RexBuilder rexBuilder) {
+ if (childRexNodeLst.size() == 2) {
+ return rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, childRexNodeLst);
+ }
Review Comment:
I don't know... Calcite's code just creates an IN with one element in this
case, which is not incorrect (and I guess it's the expected behavior). I've
just kept this special case on Hive's side for the moment to minimize side
effects by this refactoring.
--
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]