mihaibudiu commented on code in PR #4315:
URL: https://github.com/apache/calcite/pull/4315#discussion_r2050000602
##########
core/src/main/java/org/apache/calcite/rel/rules/JoinConditionOrExpansionRule.java:
##########
@@ -192,6 +185,27 @@ private boolean isJoinKeyCond(RexCall call, int
leftFieldCount) {
return false;
}
+ private boolean containNonOrOneInputRef(RexNode rex) {
+ RexInputRefCounter counter = new RexInputRefCounter();
+ rex.accept(counter);
+ return counter.inputRefCount < 2;
+ }
+
+ /**
+ * Counts the number of InputRefs in a RexNode expression. */
+ private static class RexInputRefCounter extends RexVisitorImpl<Void> {
+ public int inputRefCount = 0;
Review Comment:
counting RexInputRef is not what you want.
What you want to see is whether the reference is in the left or right input
of the join.
So you need to pass the leftFieldCount.
##########
core/src/main/java/org/apache/calcite/rel/rules/JoinConditionOrExpansionRule.java:
##########
@@ -159,21 +159,14 @@ private boolean isValidCond(RexNode node, int
leftFieldCount) {
return false;
}
- // Check if call is a binary expression.
- if (call.getOperands().size() == 2) {
- RexNode left = call.getOperands().get(0);
- RexNode right = call.getOperands().get(1);
- if (!(left instanceof RexLiteral) && !(right instanceof RexLiteral)) {
- return false;
- }
- } else {
+ if (!containNonOrOneInputRef(call)) {
Review Comment:
Maybe `doesNotReferToBothInputs`?
--
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]