wojustme commented on a change in pull request #2686:
URL: https://github.com/apache/calcite/pull/2686#discussion_r784604221



##########
File path: core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
##########
@@ -9004,6 +9005,38 @@ LogicalProject(EXPR$0=[$1], EXPR$1=[$0])
           LogicalTableScan(table=[[CATALOG, SALES, EMP]])
         LogicalProject(ENAME=[$0])
           LogicalTableScan(table=[[CATALOG, SALES, BONUS]])
+]]>
+    </Resource>
+  </TestCase>
+  <TestCase name="testPushProjectPastLeftJoin2">
+    <Resource name="sql">
+      <![CDATA[select coalesce(d.name, b.job, '')
+from emp e
+left join bonus b on e.ename = b.ename
+left join dept d on e.deptno = d.deptno]]>
+    </Resource>
+    <Resource name="planBefore">
+      <![CDATA[
+LogicalProject(EXPR$0=[CASE(IS NOT NULL($14), CAST($14):VARCHAR(10) NOT NULL, 
IS NOT NULL($10), CAST($10):VARCHAR(10) NOT NULL, '':VARCHAR(10))])
+  LogicalJoin(condition=[=($7, $13)], joinType=[left])
+    LogicalJoin(condition=[=($1, $9)], joinType=[left])
+      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+      LogicalTableScan(table=[[CATALOG, SALES, BONUS]])
+    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
+]]>
+    </Resource>
+    <Resource name="planAfter">
+      <![CDATA[
+LogicalProject(EXPR$0=[CASE(IS NOT NULL($4), CAST($4):VARCHAR(10) NOT NULL, 
$1, $2, '':VARCHAR(10))])
+  LogicalJoin(condition=[=($0, $3)], joinType=[left])
+    LogicalProject(DEPTNO=[$1], EXPR$0=[IS NOT NULL($3)], 
EXPR$1=[CAST($3):VARCHAR(10) NOT NULL])

Review comment:
       @NobiGo 
   It's good question for me. 
   In my project, we use calcite as an sql-proxy, and send dialectal sql to 
various query engine.
   `EXPR$1=[CAST($3):VARCHAR(10) NOT NULL])` will be translated to sql fragment 
of `CAST(job AS VARCHAR)`
   So, I didn't pay attention to this problem. I try to find some codes or docs 
to explain this question.
   
   In calcite's linq4j, `CAST($3):VARCHAR(10) NOT NULL` will be translated to 
`input_isNull0 ? (String) null : input_value0`
   
   




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


Reply via email to