zabetak commented on code in PR #2935:
URL: https://github.com/apache/calcite/pull/2935#discussion_r1003201432
##########
core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml:
##########
@@ -3058,6 +3058,50 @@ LogicalSort(sort0=[$7], dir0=[ASC], fetch=[0])
<Resource name="planAfter">
<![CDATA[
LogicalValues(tuples=[[]])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testEmptyTable">
+ <Resource name="sql">
+ <![CDATA[select * from EMPTY_PRODUCTS
+]]>
+ </Resource>
+ <Resource name="planBefore">
+ <![CDATA[
+LogicalProject(PRODUCTID=[$0], NAME=[$1], SUPPLIERID=[$2])
+ LogicalTableScan(table=[[CATALOG, SALES, EMPTY_PRODUCTS]])
+]]>
+ </Resource>
+ <Resource name="planAfter">
+ <![CDATA[
+LogicalValues(tuples=[[]])
+]]>
+ </Resource>
+ </TestCase>
+ <TestCase name="testEmptyTableInComplexQuery">
+ <Resource name="sql">
+ <![CDATA[select * from products left join (select * from products as e
+ inner join EMPTY_PRODUCTS as d on e.PRODUCTID = d.PRODUCTID where
e.SUPPLIERID > 10) dt
+ on products.PRODUCTID = dt.PRODUCTID]]>
+ </Resource>
+ <Resource name="planBefore">
+ <![CDATA[
+LogicalProject(PRODUCTID=[$0], NAME=[$1], SUPPLIERID=[$2], PRODUCTID0=[$3],
NAME0=[$4], SUPPLIERID0=[$5], PRODUCTID00=[$6], NAME00=[$7], SUPPLIERID00=[$8])
+ LogicalJoin(condition=[=($0, $3)], joinType=[left])
+ LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS]])
+ LogicalProject(PRODUCTID=[$0], NAME=[$1], SUPPLIERID=[$2],
PRODUCTID0=[$3], NAME0=[$4], SUPPLIERID0=[$5])
+ LogicalFilter(condition=[>($2, 10)])
+ LogicalJoin(condition=[=($0, $3)], joinType=[inner])
+ LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS]])
+ LogicalTableScan(table=[[CATALOG, SALES, EMPTY_PRODUCTS]])
+]]>
+ </Resource>
+ <Resource name="planAfter">
+ <![CDATA[
+LogicalProject(PRODUCTID=[$0], NAME=[$1], SUPPLIERID=[$2], PRODUCTID0=[$3],
NAME0=[$4], SUPPLIERID0=[$5], PRODUCTID00=[$6], NAME00=[$7], SUPPLIERID00=[$8])
+ LogicalJoin(condition=[=($0, $3)], joinType=[left])
Review Comment:
What I had in mind is something like
https://github.com/apache/calcite/pull/2935/commits/f4d0777db3f2f8618c8d796024e9bd3db4f733f8.
--
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]