2010YOUY01 commented on code in PR #17482:
URL: https://github.com/apache/datafusion/pull/17482#discussion_r2425435505


##########
datafusion/sqllogictest/test_files/pwmj.slt:
##########
@@ -0,0 +1,226 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#   http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+

Review Comment:
   For additional test coverage, we can include the following cases in this 
test file:
   1. nulls in the compare key column
   2. different projections like `select *`
   3. Expressions in the join predicate like `on t1.v1 < (t2.v1+1)`, it should 
also be able to use pwmj



##########
datafusion/sqllogictest/test_files/joins.slt:
##########
@@ -5191,6 +5206,40 @@ SELECT c
 8
 9
 
+# PiecewiseMergeJoin Test
+statement ok
+set datafusion.optimizer.allow_piecewise_merge_join = true;
+
+query II
+SELECT join_t1.t1_id, join_t2.t2_id
+FROM join_t1
+INNER JOIN join_t2 ON join_t1.t1_id > join_t2.t2_id
+WHERE join_t1.t1_id > 10 AND join_t2.t2_int > 1
+ORDER BY 1
+----
+22 11
+33 11
+44 11
+
+query TT
+EXPLAIN
+SELECT join_t1.t1_id, join_t2.t2_id
+FROM join_t1
+INNER JOIN join_t2 ON join_t1.t1_id > join_t2.t2_id
+WHERE join_t1.t1_id > 10 AND join_t2.t2_int > 1
+ORDER BY 1
+----
+physical_plan
+01)SortExec: expr=[t1_id@0 ASC NULLS LAST], preserve_partitioning=[false]
+02)--PiecewiseMergeJoin: operator=Gt, join_type=Inner, on=(t1_id > t2_id)
+03)----SortExec: expr=[t1_id@0 ASC NULLS LAST], preserve_partitioning=[false]
+04)------CoalesceBatchesExec: target_batch_size=3
+05)--------FilterExec: t1_id@0 > 10
+06)----------DataSourceExec: partitions=1, partition_sizes=[1]
+07)----CoalesceBatchesExec: target_batch_size=3
+08)------FilterExec: t2_int@1 > 1, projection=[t2_id@0]
+09)--------DataSourceExec: partitions=1, partition_sizes=[1]
+

Review Comment:
   ```suggestion
   
   # PiecewiseMergeJoin Test cleanup
   statement ok
   set datafusion.optimizer.allow_piecewise_merge_join = false;
   ```



##########
datafusion/common/src/config.rs:
##########
@@ -840,6 +840,10 @@ config_namespace! {
         /// HashJoin can work more efficiently than SortMergeJoin but consumes 
more memory
         pub prefer_hash_join: bool, default = true
 
+        /// When set to true, piecewise merge join is enabled. 
PiecewiseMergeJoin is currently

Review Comment:
   We should also indicate under what condition, the planner/optimizer will opt 
for pmwj when it's enabled



##########
datafusion/sqllogictest/test_files/joins.slt:
##########
@@ -4196,6 +4196,21 @@ SELECT * FROM t0 FULL JOIN t1 ON t0.c1 = t1.c1 LIMIT 20;
 3 3 3 3 true
 4 4 NULL NULL NULL
 
+query TT rowsort

Review Comment:
   what's the purpose of this test case?



##########
datafusion/common/src/config.rs:
##########
@@ -840,6 +840,10 @@ config_namespace! {
         /// HashJoin can work more efficiently than SortMergeJoin but consumes 
more memory
         pub prefer_hash_join: bool, default = true
 
+        /// When set to true, piecewise merge join is enabled. 
PiecewiseMergeJoin is currently
+        /// experimental.
+        pub allow_piecewise_merge_join: bool, default = false

Review Comment:
   How about using `enable_` instead of `allow_`? This seems more idiomatic.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to