rubenada commented on a change in pull request #1616: [CALCITE-3535] 
EnumerableJoinRule: remove unnecessary Filter on top of INNER Join
URL: https://github.com/apache/calcite/pull/1616#discussion_r355405116
 
 

 ##########
 File path: core/src/test/java/org/apache/calcite/test/JdbcTest.java
 ##########
 @@ -2703,12 +2703,11 @@ private void 
checkNullableTimestamp(CalciteAssert.Config config) {
         .query("select empno, desc from sales.emps,\n"
             + "  (SELECT * FROM (VALUES (10, 'SameName')) AS t (id, desc)) as 
sn\n"
             + "where emps.deptno = sn.id and sn.desc = 'SameName' group by 
empno, desc")
-        .explainContains("EnumerableCalc(expr#0..1=[{inputs}], EMPNO=[$t1], 
DESC=[$t0])\n"
-            + "  EnumerableAggregate(group=[{1, 2}])\n"
-            + "    EnumerableCalc(expr#0..3=[{inputs}], 
expr#4=[CAST($t3):INTEGER NOT NULL], expr#5=[=($t4, $t0)], expr#6=['SameName'], 
expr#7=[=($t1, $t6)], expr#8=[AND($t5, $t7)], proj#0..3=[{exprs}], 
$condition=[$t8])\n"
-            + "      EnumerableHashJoin(condition=[true], joinType=[inner])\n"
-            + "        EnumerableValues(tuples=[[{ 10, 'SameName' }]])\n"
-            + "        EnumerableTableScan(table=[[SALES, EMPS]])\n")
+        .explainContains("EnumerableAggregate(group=[{0, 3}])\n"
+            + "  EnumerableNestedLoopJoin(condition=[=(CAST($1):INTEGER NOT 
NULL, $2)], joinType=[inner])\n"
 
 Review comment:
   Good question. This is not identified as an equi-join, because in 
JoinInfo.java (and, if I am not mistaken, in Calcite in general) equi-join 
conditions must be `field = field`, i.e. something like `$1 = $2`. In this case 
we do not have a `field = field` expression, but instead a `call = field`; that 
is why `CAST($1, INTEGER NOT NULL) =  $2` is not identified as equi-join. This 
is the expected behavior.
   
   As a said note, this could be avoided by adding a projection before the 
Join, so that the expression `CAST($1):INTEGER NOT NULL` becomes a field, and 
thus the join condition an equi-join. Such transformation can be triggered by 
JoinPushExpressionsRule; but it seems that this is not the case in this 
specific test.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to