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/10/25 15:47:31 UTC

[GitHub] [arrow-datafusion] Dandandan opened a new pull request, #3958: Implement right semi join and support in HashBuildProbeorder

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

   # 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 #3945
   
    # 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 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] Dandandan commented on pull request #3958: Implement right semi join and support in HashBuildProbeorder

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

   > Filed - #3987
   
   Thanks @tustvold 


-- 
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 #3958: Implement right semi join and support in HashBuildProbeorder

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


##########
datafusion/core/src/physical_optimizer/hash_build_probe_order.rs:
##########
@@ -70,8 +70,13 @@ fn should_swap_join_order(left: &dyn ExecutionPlan, right: &dyn ExecutionPlan) -
 
 fn supports_swap(join_type: JoinType) -> bool {
     match join_type {
-        JoinType::Inner | JoinType::Left | JoinType::Right | JoinType::Full => true,
-        JoinType::Semi | JoinType::Anti => false,
+        JoinType::Inner
+        | JoinType::Left
+        | JoinType::Right
+        | JoinType::Full
+        | JoinType::Semi

Review Comment:
   We could add the new variants and mark the old ones as deprecated?



-- 
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] Dandandan commented on pull request #3958: Implement right semi join and support in HashBuildProbeorder

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

   Ok - I went ahead and renamed everything to LeftSemi and LeftAnti. I don't think it's worth the complexity to keep Semi and Anti around as depricated (as this would cause extra cases everywhere and making this error prone).


-- 
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] Dandandan commented on pull request #3958: Implement right semi join and support in HashBuildProbeorder

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

   @tustvold Is there anything I should do to update the generated pbjson and prost files? I have merged master to this version, but can't seem to generate the same code :/


-- 
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] xudong963 commented on a diff in pull request #3958: Implement right semi join and support in HashBuildProbeorder

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


##########
datafusion/core/src/physical_optimizer/hash_build_probe_order.rs:
##########
@@ -70,8 +70,13 @@ fn should_swap_join_order(left: &dyn ExecutionPlan, right: &dyn ExecutionPlan) -
 
 fn supports_swap(join_type: JoinType) -> bool {
     match join_type {
-        JoinType::Inner | JoinType::Left | JoinType::Right | JoinType::Full => true,
-        JoinType::Semi | JoinType::Anti => false,
+        JoinType::Inner
+        | JoinType::Left
+        | JoinType::Right
+        | JoinType::Full
+        | JoinType::Semi

Review Comment:
   It's better to change `JoinType::Semi` to `JoinType::LeftSemi` explictly?



-- 
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] Dandandan commented on pull request #3958: Implement right semi join and support in HashBuildProbeorder

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

   > Nice work, thank you @Dandandan
   > 
   > Lol, btw I just finished all kinds of right-related join in databend community a few days ago to make join reorder work smoothly.
   
   Awesome - would be nice to see if we can learn something from databend :+1: 


-- 
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] tustvold commented on pull request #3958: Implement right semi join and support in HashBuildProbeorder

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

   Filed - https://github.com/apache/arrow-datafusion/pull/3987


-- 
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] ursabot commented on pull request #3958: Implement right semi join and support in HashBuildProbeorder

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

   Benchmark runs are scheduled for baseline = e73a43cd6ef1d33feb9214d29843a768477a62b0 and contender = 002165b55beb3aeb15ad4d9955295af7ff045945. 002165b55beb3aeb15ad4d9955295af7ff045945 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/8e0998d0dcfa418c914040474a8c7bab...ff3b9965d6984475a55ba6140b60eaec/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/d5d6219f24ee453680e922a01ea82b2f...a392d308241d43c29fccff55def3bdb4/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/116e84e2f18f450eab614219346c1825...e09f556813e54b139ee13f1c204850ee/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/a7363848a88942458d7413102f3f4d08...aadadf22f6584f30a2a0ea4dc498e7cd/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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 #3958: Implement right semi join and support in HashBuildProbeorder

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


##########
datafusion/core/src/physical_plan/joins/hash_join.rs:
##########
@@ -2116,6 +2171,48 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn join_right_semi() -> Result<()> {
+        let session_ctx = SessionContext::new();
+        let task_ctx = session_ctx.task_ctx();
+        let left = build_table(
+            ("a2", &vec![10, 20, 30, 40]),
+            ("b1", &vec![4, 5, 6, 5]), // 5 is double on the left

Review Comment:
   recommend calling this `b2` not `b1` for clarity



-- 
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] Dandandan merged pull request #3958: Implement right semi join and support in HashBuildProbeorder

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


-- 
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] Dandandan commented on a diff in pull request #3958: Implement right semi join and support in HashBuildProbeorder

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


##########
datafusion/core/src/physical_optimizer/hash_build_probe_order.rs:
##########
@@ -70,8 +70,13 @@ fn should_swap_join_order(left: &dyn ExecutionPlan, right: &dyn ExecutionPlan) -
 
 fn supports_swap(join_type: JoinType) -> bool {
     match join_type {
-        JoinType::Inner | JoinType::Left | JoinType::Right | JoinType::Full => true,
-        JoinType::Semi | JoinType::Anti => false,
+        JoinType::Inner
+        | JoinType::Left
+        | JoinType::Right
+        | JoinType::Full
+        | JoinType::Semi

Review Comment:
   That might be better for clarity, but also a breaking change.
   I think we also should change Anti to LeftAnti if we want to do this.
   
   FYI @alamb @andygrove 



-- 
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] Dandandan commented on pull request #3958: Implement right semi join and support in HashBuildProbeorder

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

   > `parquet-testing` was changed, is it expected?
   > 
   > Maybe the change will break some tests.
   
   My mistake! Thanks, fixed.


-- 
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] Dandandan commented on a diff in pull request #3958: Implement right semi join and support in HashBuildProbeorder

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


##########
datafusion/proto/src/generated/pbjson.rs:
##########
@@ -43,7 +43,6 @@ impl<'de> serde::Deserialize<'de> for AggregateExprNode {
         D: serde::Deserializer<'de>,
     {
         const FIELDS: &[&str] = &[
-            "aggr_function",

Review Comment:
   I only get `aggrFunction`



-- 
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 #3958: Implement right semi join and support in HashBuildProbeorder

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


##########
datafusion/core/src/physical_plan/joins/hash_join.rs:
##########
@@ -2116,6 +2171,48 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn join_right_semi() -> Result<()> {
+        let session_ctx = SessionContext::new();
+        let task_ctx = session_ctx.task_ctx();
+        let left = build_table(
+            ("a2", &vec![10, 20, 30, 40]),
+            ("b1", &vec![4, 5, 6, 5]), // 5 is double on the left
+            ("c2", &vec![70, 80, 90, 100]),
+        );
+        let right = build_table(
+            ("a1", &vec![1, 2, 2, 3]),
+            ("b1", &vec![4, 5, 5, 7]), // 7 does not exist on the left

Review Comment:
   I recommend changing this so `5` is not duplicated -- otherwise the output looks like an equijoin



-- 
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] Dandandan commented on pull request #3958: Implement right semi join and support in HashBuildProbeorder

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

   @tustvold Updating the lock-file solved the issue. Might be something to think about if that happens too often (at least document that this could be a reason)? 
   
   I saw the related update:
   ```
       Updating pbjson-build v0.5.0 -> v0.5.1
       Updating pbjson-types v0.5.0 -> v0.5.1
   ```
   
   Might be something


-- 
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] Dandandan commented on a diff in pull request #3958: Implement right semi join and support in HashBuildProbeorder

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


##########
datafusion/core/src/physical_plan/joins/hash_join.rs:
##########
@@ -2116,6 +2171,48 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn join_right_semi() -> Result<()> {
+        let session_ctx = SessionContext::new();
+        let task_ctx = session_ctx.task_ctx();
+        let left = build_table(
+            ("a2", &vec![10, 20, 30, 40]),
+            ("b1", &vec![4, 5, 6, 5]), // 5 is double on the left
+            ("c2", &vec![70, 80, 90, 100]),
+        );
+        let right = build_table(
+            ("a1", &vec![1, 2, 2, 3]),
+            ("b1", &vec![4, 5, 5, 7]), // 7 does not exist on the left

Review Comment:
   For the right semi join also duplicates on the right must be maintained. So I think keeping that makes sense? 
   It is reflected in the output - if it was an equijoin it would have resulted in 4 rows...



##########
datafusion/core/src/physical_plan/joins/hash_join.rs:
##########
@@ -2116,6 +2171,48 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn join_right_semi() -> Result<()> {
+        let session_ctx = SessionContext::new();
+        let task_ctx = session_ctx.task_ctx();
+        let left = build_table(
+            ("a2", &vec![10, 20, 30, 40]),
+            ("b1", &vec![4, 5, 6, 5]), // 5 is double on the left
+            ("c2", &vec![70, 80, 90, 100]),
+        );
+        let right = build_table(
+            ("a1", &vec![1, 2, 2, 3]),
+            ("b1", &vec![4, 5, 5, 7]), // 7 does not exist on the left

Review Comment:
   For the right semi join also duplicates on the right must be maintained. So I think keeping that makes sense? 
   It is reflected in the output - if it was an equijoin it would have resulted in 4 rows with b1=5...



-- 
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] Dandandan commented on a diff in pull request #3958: Implement right semi join and support in HashBuildProbeorder

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


##########
datafusion/core/src/physical_plan/joins/hash_join.rs:
##########
@@ -2116,6 +2171,48 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn join_right_semi() -> Result<()> {
+        let session_ctx = SessionContext::new();
+        let task_ctx = session_ctx.task_ctx();
+        let left = build_table(
+            ("a2", &vec![10, 20, 30, 40]),
+            ("b1", &vec![4, 5, 6, 5]), // 5 is double on the left

Review Comment:
   makes sense



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