Dandandan commented on code in PR #7670:
URL: https://github.com/apache/arrow-datafusion/pull/7670#discussion_r1339835685


##########
datafusion/optimizer/src/push_down_projection.rs:
##########
@@ -977,6 +974,35 @@ mod tests {
         assert_optimized_plan_eq(&plan, expected)
     }
 
+    #[test]
+    fn table_full_filter_pushdown() -> Result<()> {
+        let schema = Schema::new(test_table_scan_fields());
+
+        let table_scan = table_scan_with_filters(
+            Some("test"),
+            &schema,
+            None,
+            vec![col("b").eq(lit(1))],
+        )?
+        .build()?;
+        assert_eq!(3, table_scan.schema().fields().len());
+        assert_fields_eq(&table_scan, vec!["a", "b", "c"]);
+
+        // there is no need for the first projection
+        let plan = LogicalPlanBuilder::from(table_scan)
+            .project(vec![col("b")])?
+            .project(vec![lit(1).alias("a")])?
+            .build()?;
+
+        assert_fields_eq(&plan, vec!["a"]);
+
+        let expected = "\
+        Projection: Int32(1) AS a\
+        \n  TableScan: test projection=[a], full_filters=[b = Int32(1)]";

Review Comment:
   Here is the important fix - before this would add `b` to the projection 
(even if it was not needed in the plan above). This would lead to unnecessary 
scanning the table. 



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