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/18 22:06:35 UTC

[GitHub] [arrow-datafusion] andygrove opened a new pull request, #2575: WIP: Remove `Union::alias`

andygrove opened a new pull request, #2575:
URL: https://github.com/apache/arrow-datafusion/pull/2575

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Builds on https://github.com/apache/arrow-datafusion/pull/2574 so we need to merge that first
   
   Closes https://github.com/apache/arrow-datafusion/issues/2213
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   The `alias` attribute in `Union` was actually only used from a single test so wasn't really needed.
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   - Remove `Union.alias` and the one test that used it
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   API change
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


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


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

Posted by GitBox <gi...@apache.org>.
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


[GitHub] [arrow-datafusion] andygrove commented on pull request #2575: WIP: Remove `Union::alias`

Posted by GitBox <gi...@apache.org>.
andygrove commented on PR #2575:
URL: https://github.com/apache/arrow-datafusion/pull/2575#issuecomment-1143812244

   Closing this for now and will take another run at this soon


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


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

Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #2575:
URL: https://github.com/apache/arrow-datafusion/pull/2575#discussion_r878701773


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

Review Comment:
   On second thoughts, the test is about using a filter with an alias ... :thinking: ... ok I will look into this more



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


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

Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #2575:
URL: https://github.com/apache/arrow-datafusion/pull/2575#discussion_r878699688


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

Review Comment:
   The test is specifically testing for creating a union with an alias, which we no longer support



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


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

Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #2575:
URL: https://github.com/apache/arrow-datafusion/pull/2575#discussion_r878176903


##########
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();

Review Comment:
   This logic is moved from the `union_with_alias` function but no longer references the alias



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


[GitHub] [arrow-datafusion] andygrove commented on pull request #2575: WIP: Remove `Union::alias`

Posted by GitBox <gi...@apache.org>.
andygrove commented on PR #2575:
URL: https://github.com/apache/arrow-datafusion/pull/2575#issuecomment-1130602166

   @jackwener fyi


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


[GitHub] [arrow-datafusion] andygrove closed pull request #2575: WIP: Remove `Union::alias`

Posted by GitBox <gi...@apache.org>.
andygrove closed pull request #2575: WIP: Remove `Union::alias`
URL: https://github.com/apache/arrow-datafusion/pull/2575


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