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/04/14 22:52:58 UTC

[GitHub] [arrow-datafusion] Dandandan opened a new pull request, #2240: Fix join without constraints

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

   # 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 #2230
   
    # 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.
   -->
   
   Fixes join without on constraint.
   Also adds explicit check for non-empty constraint list in HashJoinExec
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   No
   
   <!--
   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] yjshen merged pull request #2240: Fix join without constraints

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


-- 
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 #2240: Fix join without constraints

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


##########
datafusion/core/src/sql/planner.rs:
##########
@@ -524,7 +524,18 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                     keys.into_iter().unzip();
 
                 // return the logical plan representing the join
-                if filter.is_empty() {
+                if left_keys.is_empty() {
+                    // When we don't have join keys, use cross join

Review Comment:
   yeah, that is the classic implementation, infortunately



##########
datafusion/core/src/sql/planner.rs:
##########
@@ -524,7 +524,18 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                     keys.into_iter().unzip();
 
                 // return the logical plan representing the join
-                if filter.is_empty() {
+                if left_keys.is_empty() {
+                    // When we don't have join keys, use cross join
+                    let join = LogicalPlanBuilder::from(left).cross_join(&right)?;
+
+                    let join_filter_init = filter.remove(0);
+                    join.filter(
+                        filter
+                            .into_iter()
+                            .fold(join_filter_init, |acc, e| acc.and(e)),
+                    )?
+                    .build()

Review Comment:
   I wonder if you can use `reduce` here rather than fold: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.reduce
   
   Something like (untested):
   
   ```suggestion
                       join.filter(
                           filter
                               .reduce(|acc, e| acc.and(e)),
                       )?
                       .build()
   ```
   
   



-- 
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 #2240: Fix join without constraints

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


##########
datafusion/core/src/sql/planner.rs:
##########
@@ -537,13 +543,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
                         join_type,
                         (left_keys, right_keys),
                     )?;
-                    let join_filter_init = filter.remove(0);
-                    join.filter(
-                        filter
-                            .into_iter()
-                            .fold(join_filter_init, |acc, e| acc.and(e)),
-                    )?
-                    .build()
+                    join.filter(filter.into_iter().reduce(Expr::and).unwrap())?

Review Comment:
   ❤️ 



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