gene-bordegaray commented on code in PR #23484:
URL: https://github.com/apache/datafusion/pull/23484#discussion_r3610609389


##########
datafusion/core/tests/physical_optimizer/enforce_distribution.rs:
##########
@@ -870,6 +870,87 @@ fn 
range_inner_hash_join_rehashes_incompatible_range_partitioning() -> Result<()
     Ok(())
 }
 
+// Kept as a unit test: `RightMark` join plans cannot be produced from SQL 
(they
+// only arise when a statistical swap flips a `LeftMark` join around), so this
+// reuse plan shape has no `range_partitioning.slt` equivalent. The end-to-end
+// mark-join coverage lives in that file's "Mark Join Marker Semantics" case.
+#[test]
+fn range_right_mark_hash_join_reuses_range_partitioning() -> Result<()> {
+    let left = parquet_exec_with_output_partitioning(range_partitioning(
+        "a",
+        [10, 20, 30],
+        SortOptions::default(),
+    )?);
+    let right = parquet_exec_with_output_partitioning(range_partitioning(
+        "a",
+        [10, 20, 30],
+        SortOptions::default(),
+    )?);
+    let join_on = vec![(
+        Arc::new(Column::new_with_schema("a", &left.schema())?) as _,
+        Arc::new(Column::new_with_schema("a", &right.schema())?) as _,
+    )];
+    let join = hash_join_exec(left, right, &join_on, &JoinType::RightMark);
+
+    let plan = TestConfig::default()
+        .with_query_execution_partitions(4)
+        .to_plan(join, &DISTRIB_DISTRIB_SORT);
+
+    assert_plan!(
+        plan,
+        @r"
+    HashJoinExec: mode=Partitioned, join_type=RightMark, on=[(a@0, a@0)]
+      DataSourceExec: file_groups={4 groups: [[p0], [p1], [p2], [p3]]}, 
projection=[a, b, c, d, e], output_partitioning=Range([a@0 ASC], [(10), (20), 
(30)], 4), file_type=parquet
+      DataSourceExec: file_groups={4 groups: [[p0], [p1], [p2], [p3]]}, 
projection=[a, b, c, d, e], output_partitioning=Range([a@0 ASC], [(10), (20), 
(30)], 4), file_type=parquet
+    "
+    );
+
+    Ok(())
+}
+
+// Kept as a unit test: a descending Range input cannot be registered through 
the
+// sqllogictest fixtures (they only declare ascending Range layouts), so the
+// sort-direction axis of the co-partition check has no 
`range_partitioning.slt`
+// equivalent. Verifies that opposite sort options force Hash repartitioning.
+#[test]
+fn range_right_semi_hash_join_rehashes_incompatible_sort_options() -> 
Result<()> {
+    let left = parquet_exec_with_output_partitioning(range_partitioning(
+        "a",
+        [10, 20, 30],
+        SortOptions::default(),
+    )?);
+    let right = parquet_exec_with_output_partitioning(range_partitioning(
+        "a",
+        [30, 20, 10],
+        SortOptions {
+            descending: true,
+            nulls_first: true,
+        },
+    )?);

Review Comment:
   Otherwise the split points dont match and aren't really testing sort options



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