andygrove commented on code in PR #3880:
URL: https://github.com/apache/arrow-datafusion/pull/3880#discussion_r998448651


##########
datafusion/optimizer/src/projection_push_down.rs:
##########
@@ -509,7 +509,25 @@ fn optimize_plan(
 
             from_plan(plan, &expr, &new_inputs)
         }
-    }
+    };
+
+    // when this rule is applied multiple times it will insert duplicate 
nested projections,
+    // so we catch this here
+    let with_dupe_projection_removed = match new_plan? {
+        LogicalPlan::Projection(p) => match p.input.as_ref() {
+            LogicalPlan::Projection(p2) if projection_equal(&p, p2) => {
+                LogicalPlan::Projection(p2.clone())
+            }
+            _ => LogicalPlan::Projection(p),
+        },
+        other => other,
+    };

Review Comment:
   This is the fix for https://github.com/apache/arrow-datafusion/issues/3881



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