Diveyam-Mishra commented on code in PR #5048:
URL: https://github.com/apache/calcite/pull/5048#discussion_r3556880820
##########
file/src/test/java/org/apache/calcite/adapter/file/FileAdapterTest.java:
##########
@@ -417,6 +418,173 @@ private static void checkEmpty(ResultSet resultSet) {
sql("model-with-custom-table", sql).ok();
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7618">[CALCITE-7618]
+ * Add filter pushdown support to file adapter's CSV implementation</a>.
+ *
+ * <p>Verifies that a simple equality filter is pushed into {@link
CsvTableScan},
+ * eliminating the {@code EnumerableCalc} that would otherwise evaluate it.
*/
+ @Test void testFilterPushDown() {
+ final String sql = "explain plan for select * from EMPS where deptno = 20";
+ final String expected = "PLAN=CsvTableScan(table=[[SALES, EMPS]], "
+ + "fields=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], condition=[=($2, 20)])\n";
+ sql("smart", sql).returns(expected).ok();
+ }
+
+ @Test void testFilterPushDownWithProject() {
+ final String sql = "explain plan for select name, empno from EMPS where
deptno = 20";
+ final String expected = "PLAN=EnumerableCalc(expr#0..2=[{inputs}],"
Review Comment:
Yes, the filter is pushed into CsvTableScan by
CsvProjectFilterTableScanRule. During CsvTableScan.implement(), the scan
compiles its stored condition into an EnumerableCalc over a condition-less
scan, which is why the generated plan displays $condition in the calc. The
predicate is still owned by the scan before implementation and is evaluated
once through the generated calc code.
--
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]