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/11/30 05:31:12 UTC

[GitHub] [arrow-datafusion] HaoYang670 opened a new pull request, #4432: Remove the schema checking when creating `CrossJoinExec`

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

   Signed-off-by: remzi <13...@gmail.com>
   
   # 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.
   -->
   
   Closes #4431 .
   
   # 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.  
   -->
   
   # 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.
   -->
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   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 pull request #4432: Remove the schema checking when creating `CrossJoinExec`

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

   As I think all comments have been addressed, I am merging it in


-- 
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] HaoYang670 commented on a diff in pull request #4432: Remove the schema checking when creating `CrossJoinExec`

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


##########
datafusion/core/src/physical_plan/joins/cross_join.rs:
##########
@@ -61,34 +61,25 @@ pub struct CrossJoinExec {
 }
 
 impl CrossJoinExec {
-    /// Tries to create a new [CrossJoinExec].
-    /// # Error
-    /// This function errors when left and right schema's can't be combined
-    pub fn try_new(
-        left: Arc<dyn ExecutionPlan>,
-        right: Arc<dyn ExecutionPlan>,
-    ) -> Result<Self> {
-        let left_schema = left.schema();
-        let right_schema = right.schema();
-        check_join_is_valid(&left_schema, &right_schema, &[])?;
-
-        let left_schema = left.schema();
-        let left_fields = left_schema.fields().iter();
-        let right_schema = right.schema();
-
-        let right_fields = right_schema.fields().iter();
-
+    /// Create a new [CrossJoinExec].
+    pub fn new(left: Arc<dyn ExecutionPlan>, right: Arc<dyn ExecutionPlan>) -> Self {
         // left then right
-        let all_columns = left_fields.chain(right_fields).cloned().collect();
+        let all_columns = {
+            let left_schema = left.schema();
+            let right_schema = right.schema();
+            let left_fields = left_schema.fields().iter();
+            let right_fields = right_schema.fields().iter();
+            left_fields.chain(right_fields).cloned().collect()
+        };
 
         let schema = Arc::new(Schema::new(all_columns));

Review Comment:
   @andygrove, what's your suggestion?



-- 
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 #4432: Remove the schema checking when creating `CrossJoinExec`

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


##########
datafusion/core/src/physical_plan/joins/cross_join.rs:
##########
@@ -61,34 +61,25 @@ pub struct CrossJoinExec {
 }
 
 impl CrossJoinExec {
-    /// Tries to create a new [CrossJoinExec].
-    /// # Error
-    /// This function errors when left and right schema's can't be combined
-    pub fn try_new(
-        left: Arc<dyn ExecutionPlan>,
-        right: Arc<dyn ExecutionPlan>,
-    ) -> Result<Self> {
-        let left_schema = left.schema();
-        let right_schema = right.schema();
-        check_join_is_valid(&left_schema, &right_schema, &[])?;
-
-        let left_schema = left.schema();
-        let left_fields = left_schema.fields().iter();
-        let right_schema = right.schema();
-
-        let right_fields = right_schema.fields().iter();
-
+    /// Create a new [CrossJoinExec].
+    pub fn new(left: Arc<dyn ExecutionPlan>, right: Arc<dyn ExecutionPlan>) -> Self {
         // left then right
-        let all_columns = left_fields.chain(right_fields).cloned().collect();
+        let all_columns = {
+            let left_schema = left.schema();
+            let right_schema = right.schema();
+            let left_fields = left_schema.fields().iter();
+            let right_fields = right_schema.fields().iter();
+            left_fields.chain(right_fields).cloned().collect()
+        };
 
         let schema = Arc::new(Schema::new(all_columns));

Review Comment:
   Could you use `Schema::merge` here 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] HaoYang670 commented on a diff in pull request #4432: Remove the schema checking when creating `CrossJoinExec`

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


##########
datafusion/core/src/physical_plan/joins/cross_join.rs:
##########
@@ -61,34 +61,25 @@ pub struct CrossJoinExec {
 }
 
 impl CrossJoinExec {
-    /// Tries to create a new [CrossJoinExec].
-    /// # Error
-    /// This function errors when left and right schema's can't be combined
-    pub fn try_new(
-        left: Arc<dyn ExecutionPlan>,
-        right: Arc<dyn ExecutionPlan>,
-    ) -> Result<Self> {
-        let left_schema = left.schema();
-        let right_schema = right.schema();
-        check_join_is_valid(&left_schema, &right_schema, &[])?;
-
-        let left_schema = left.schema();
-        let left_fields = left_schema.fields().iter();
-        let right_schema = right.schema();
-
-        let right_fields = right_schema.fields().iter();
-
+    /// Create a new [CrossJoinExec].
+    pub fn new(left: Arc<dyn ExecutionPlan>, right: Arc<dyn ExecutionPlan>) -> Self {
         // left then right
-        let all_columns = left_fields.chain(right_fields).cloned().collect();
+        let all_columns = {
+            let left_schema = left.schema();
+            let right_schema = right.schema();
+            let left_fields = left_schema.fields().iter();
+            let right_fields = right_schema.fields().iter();
+            left_fields.chain(right_fields).cloned().collect()
+        };
 
         let schema = Arc::new(Schema::new(all_columns));

Review Comment:
   Sorry, I'm afraid `try_merge` doesn't fit this context.
   What we want here is to **concatenate** schema, but not **merge** schema. It could happen that a table cross joins with itself, or two tables have same named columns, in which cases, `merge` doesn't work. 



-- 
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 #4432: Remove the schema checking when creating `CrossJoinExec`

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


##########
datafusion/core/src/physical_plan/joins/cross_join.rs:
##########
@@ -61,34 +61,25 @@ pub struct CrossJoinExec {
 }
 
 impl CrossJoinExec {
-    /// Tries to create a new [CrossJoinExec].
-    /// # Error
-    /// This function errors when left and right schema's can't be combined
-    pub fn try_new(
-        left: Arc<dyn ExecutionPlan>,
-        right: Arc<dyn ExecutionPlan>,
-    ) -> Result<Self> {
-        let left_schema = left.schema();
-        let right_schema = right.schema();
-        check_join_is_valid(&left_schema, &right_schema, &[])?;
-
-        let left_schema = left.schema();
-        let left_fields = left_schema.fields().iter();
-        let right_schema = right.schema();
-
-        let right_fields = right_schema.fields().iter();
-
+    /// Create a new [CrossJoinExec].
+    pub fn new(left: Arc<dyn ExecutionPlan>, right: Arc<dyn ExecutionPlan>) -> Self {
         // left then right
-        let all_columns = left_fields.chain(right_fields).cloned().collect();
+        let all_columns = {
+            let left_schema = left.schema();
+            let right_schema = right.schema();
+            let left_fields = left_schema.fields().iter();
+            let right_fields = right_schema.fields().iter();
+            left_fields.chain(right_fields).cloned().collect()
+        };
 
         let schema = Arc::new(Schema::new(all_columns));

Review Comment:
   You could do something like this. This would preserve schema metadata as well.
   
   ```rust
           let input_schemas = vec![left.schema().as_ref().clone(), right.schema().as_ref().clone()];
           let schema = Arc::new(Schema::try_merge(input_schemas)?);
   ```



-- 
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 merged pull request #4432: Remove the schema checking when creating `CrossJoinExec`

Posted by GitBox <gi...@apache.org>.
alamb merged PR #4432:
URL: https://github.com/apache/arrow-datafusion/pull/4432


-- 
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] HaoYang670 commented on a diff in pull request #4432: Remove the schema checking when creating `CrossJoinExec`

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


##########
datafusion/core/src/physical_plan/joins/cross_join.rs:
##########
@@ -61,34 +61,25 @@ pub struct CrossJoinExec {
 }
 
 impl CrossJoinExec {
-    /// Tries to create a new [CrossJoinExec].
-    /// # Error
-    /// This function errors when left and right schema's can't be combined
-    pub fn try_new(
-        left: Arc<dyn ExecutionPlan>,
-        right: Arc<dyn ExecutionPlan>,
-    ) -> Result<Self> {
-        let left_schema = left.schema();
-        let right_schema = right.schema();
-        check_join_is_valid(&left_schema, &right_schema, &[])?;
-
-        let left_schema = left.schema();
-        let left_fields = left_schema.fields().iter();
-        let right_schema = right.schema();
-
-        let right_fields = right_schema.fields().iter();
-
+    /// Create a new [CrossJoinExec].
+    pub fn new(left: Arc<dyn ExecutionPlan>, right: Arc<dyn ExecutionPlan>) -> Self {
         // left then right
-        let all_columns = left_fields.chain(right_fields).cloned().collect();
+        let all_columns = {
+            let left_schema = left.schema();
+            let right_schema = right.schema();
+            let left_fields = left_schema.fields().iter();
+            let right_fields = right_schema.fields().iter();
+            left_fields.chain(right_fields).cloned().collect()
+        };
 
         let schema = Arc::new(Schema::new(all_columns));

Review Comment:
   For the metadata, we should also do concatenation, instead of merging.



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