Skip to content

[SPARK-59438][SQL][TESTS] Add planner-stage test coverage for ASOF JOIN sort-merge operator - #58742

Draft
LukaZdravic wants to merge 1 commit into
apache:masterfrom
LukaZdravic:SPARK-59438-asof-planner-tests
Draft

[SPARK-59438][SQL][TESTS] Add planner-stage test coverage for ASOF JOIN sort-merge operator#58742
LukaZdravic wants to merge 1 commit into
apache:masterfrom
LukaZdravic:SPARK-59438-asof-planner-tests

Conversation

@LukaZdravic

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This is a test-only change that adds planner-stage (physical-planning / strategy) coverage for the ASOF JOIN sort-merge operator:

  • PlannerSuite — a new test constructs a no-equi-key SortMergeAsOfJoinExec and runs EnsureRequirements, asserting that both sides are shuffled to a single partition. This exercises the AllTuples branch of the operator's requiredChildDistribution (used when the join has no equi-keys), following the existing SortMergeJoinExec distribution tests in the same suite (SPARK-24495 / SPARK-27485).
  • SortMergeAsOfJoinSuite — a new test checks that a null-safe equi-key (<=>) in ON is routed to the residual condition rather than treated as an equi-key, so rows whose key is NULL on both sides do match. This is the counterpart to the existing EqualTo case where null keys never match, and mirrors InnerJoinSuite's "inner join, null safe" test.

No production code is changed.

Why are the changes needed?

The AsOfJoinSelection strategy and SortMergeAsOfJoinExec operator were exercised end-to-end for result correctness, but two planner-stage behaviors had no test: (1) the operator's custom requiredChildDistribution that forces a single partition when there are no equi-keys, and (2) the strategy's handling of EqualNullSafe in ON. Sibling join operators cover the analogous behaviors; this brings ASOF JOIN up to the same bar.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New unit tests. Ran PlannerSuite and SortMergeAsOfJoinSuite locally (via Maven); all tests pass.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code

…IN sort-merge operator

Adds two planner-stage tests for the ASOF JOIN sort-merge path, both
mirroring existing sibling-join test patterns:

- `PlannerSuite`: a no-equi-key `AsOfJoin` requires a single partition on
  both sides (the `AllTuples` branch of `SortMergeAsOfJoinExec`'s
  `requiredChildDistribution`), verified by running `EnsureRequirements`
  and asserting a single-partition shuffle on each side. Follows the
  existing `SortMergeJoinExec` distribution tests (SPARK-24495 /
  SPARK-27485).
- `SortMergeAsOfJoinSuite`: a null-safe (`<=>`) equi-key in `ON` is routed
  to the residual condition rather than treated as an equi-key, so null
  keys on both sides do match -- the counterpart to the existing `EqualTo`
  case where null keys never match. Mirrors `InnerJoinSuite`'s
  "inner join, null safe".

Test-only change; no production code is modified.
Copilot AI lite review requested due to automatic review settings September 11, 2026 13:56
@LukaZdravic
LukaZdravic marked this pull request as draft September 11, 2026 13:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Test-only changes with no unresolved issues.

Pull request overview

Adds test-only planner and execution coverage for ASOF JOIN behavior.

Changes:

  • Tests single-partition requirements for no-equi-key joins.
  • Tests null-safe conditions matching null keys.
File summaries
File Summary
sql/core/src/test/scala/org/apache/spark/sql/SortMergeAsOfJoinSuite.scala Adds null-safe ASOF JOIN coverage.
sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala Adds distribution requirement coverage.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants