jayzhan211 commented on code in PR #25839:
URL: https://github.com/apache/datafusion/pull/25839#discussion_r4260132229


##########
benchmarks/sql_benchmarks/pwmj/pwmj.benchmark.template:
##########
@@ -0,0 +1,51 @@
+# Shared template for the `pwmj` suite: `PiecewiseMergeJoin`'s classic joins
+# (INNER / LEFT / RIGHT / FULL) over a single range predicate,
+# `lhs.key < rhs.key`.
+#
+# Parameters set by each qNN.benchmark:
+#   QPAD           zero-padded query id
+#   JOIN           SQL join keyword       (INNER, LEFT, RIGHT, FULL)
+#   JOIN_KIND      plan `join_type`       (Inner, Left, Right, Full)
+#   RIGHT_ROWS     streamed row count
+#   RIGHT_KEY      streamed key expression over `value` and its scramble `h`
+#   EXPECTED_ROWS  rows the join returns, asserted before measuring
+#
+# `lhs` (buffered) holds the keys 1..=100000; a streamed key `b` matches 
exactly
+# the buffered keys 1..b, so each subgroup is a different match regime (see
+# init/load.sql). There is no nested-loop arm: at these sizes it is 2 * 10^11
+# predicate evaluations.
+
+load sql_benchmarks/pwmj/init/load.sql
+
+init sql_benchmarks/pwmj/init/settings.sql
+
+name Q${QPAD}
+group pwmj
+
+# PWMJ is off by default. Without the flag every query plans as a nested-loop
+# join and the suite measures a different operator than its name claims.
+assert I
+SELECT value = 'true' FROM information_schema.df_settings WHERE name = 
'datafusion.optimizer.enable_piecewise_merge_join';
+----
+true
+
+# The row count follows from the keys alone, so a wrong join result fails here
+# rather than showing up as a plausible timing.
+assert I
+SELECT count(*) FROM lhs ${JOIN} JOIN rhs ON lhs.key < rhs.key;
+----
+${EXPECTED_ROWS}
+
+# Pin the operator and the join type: the flag only permits PWMJ, and a planner
+# that swapped the inputs would measure the mirrored join. `expect_plan` 
matches
+# the plan's `Debug` output, so the fields are checked one at a time.
+expect_plan PiecewiseMergeJoinExec

Review Comment:
   Since #25441, `expect_plan` matches the plan text that `EXPLAIN` shows 
(`DisplayableExecutionPlan`), not `Debug`. For this plan that text is 
`PiecewiseMergeJoin: operator=Lt, join_type=Inner, on=(key < key)`. None of 
`PiecewiseMergeJoinExec`, `operator: Lt,` or `join_type: Inner,` appear in it, 
so all 20 queries fail with "The query physical plan does not contain the 
expected string" before measuring. One check covers all three:
   
   ```diff
   -# that swapped the inputs would measure the mirrored join. `expect_plan` 
matches
   -# the plan's `Debug` output, so the fields are checked one at a time.
   -expect_plan PiecewiseMergeJoinExec
   -
   -expect_plan operator: Lt,
   -
   -expect_plan join_type: ${JOIN_KIND},
   +# that swapped the inputs would measure the mirrored join. `expect_plan` 
matches
   +# the plan as `EXPLAIN` displays it; the trailing comma keeps `Left` from
   +# matching `LeftSemi`/`LeftAnti`/`LeftMark`.
   +expect_plan PiecewiseMergeJoin: operator=Lt, join_type=${JOIN_KIND},
   ```



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