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 2022/05/21 11:22:31 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2575: Remove `Union::alias`

alamb commented on code in PR #2575:
URL: https://github.com/apache/arrow-datafusion/pull/2575#discussion_r878683861


##########
datafusion/core/src/logical_plan/builder.rs:
##########
@@ -432,8 +432,50 @@ impl LogicalPlanBuilder {
     }
 
     /// Apply a union, preserving duplicate rows
-    pub fn union(&self, plan: LogicalPlan) -> Result<Self> {
-        Ok(Self::from(union_with_alias(self.plan.clone(), plan, None)?))
+    pub fn union(&self, right_plan: LogicalPlan) -> Result<Self> {
+        let left_plan = self.plan.clone();
+        let union_schema = left_plan.schema().clone();
+        let inputs_iter = vec![left_plan, right_plan]
+            .into_iter()
+            .flat_map(|p| match p {
+                LogicalPlan::Union(Union { inputs, .. }) => inputs,
+                x => vec![x],
+            });
+
+        inputs_iter
+            .clone()
+            .skip(1)
+            .try_for_each(|input_plan| -> Result<()> {
+                union_schema.check_arrow_schema_type_compatible(
+                    &((**input_plan.schema()).clone().into()),

Review Comment:
   `&((**` is definitely hard on the eyes (though I realize it wasn't introduced in this PR)



##########
datafusion/core/src/optimizer/filter_push_down.rs:
##########
@@ -894,27 +889,6 @@ mod tests {
         Ok(())
     }
 
-    #[test]
-    fn union_all_with_alias() -> Result<()> {

Review Comment:
   Rather than remove this test, what about updating it to use `LogicalPlanBuilder::union` instead?



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