You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/07/19 16:29:30 UTC

[GitHub] [arrow-datafusion] alamb commented on a change in pull request #747: Remove unnecessary projection in logical plan optimization phase

alamb commented on a change in pull request #747:
URL: https://github.com/apache/arrow-datafusion/pull/747#discussion_r672448317



##########
File path: datafusion/src/optimizer/projection_push_down.rs
##########
@@ -496,6 +506,60 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn redundunt_project() -> Result<()> {

Review comment:
       ```suggestion
       fn redundant_project() -> Result<()> {
   ```

##########
File path: datafusion/src/optimizer/projection_push_down.rs
##########
@@ -496,6 +506,60 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn redundunt_project() -> Result<()> {
+        let table_scan = test_table_scan()?;
+
+        let plan = LogicalPlanBuilder::from(table_scan)
+            .project(vec![col("a"), col("b"), col("c")])?
+            .project(vec![col("a"), col("c"), col("b")])?
+            .build()?;
+        let expected = "Projection: #test.a, #test.c, #test.b\
+        \n  TableScan: test projection=Some([0, 1, 2])";
+
+        assert_optimized_plan_eq(&plan, expected);
+
+        Ok(())
+    }
+
+    #[test]
+    fn reorder_projection() -> Result<()> {
+        let table_scan = test_table_scan()?;
+
+        let plan = LogicalPlanBuilder::from(table_scan)
+            .project(vec![col("c"), col("b"), col("a")])?
+            .build()?;
+        let expected = "Projection: #test.c, #test.b, #test.a\
+        \n  TableScan: test projection=Some([0, 1, 2])";
+
+        assert_optimized_plan_eq(&plan, expected);
+
+        Ok(())
+    }
+
+    #[test]
+    fn noncontiguous_redundunt_projection() -> Result<()> {

Review comment:
       ```suggestion
       fn noncontiguous_redundant_projection() -> Result<()> {
   ```




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org