Skip to content

Merge ANTI JOIN should preserve unmatched NULL keys - #5242

Draft
bvolpato wants to merge 1 commit into
apache:mainfrom
bvolpato:bvolpato/fix-merge-anti-null-keys
Draft

Merge ANTI JOIN should preserve unmatched NULL keys#5242
bvolpato wants to merge 1 commit into
apache:mainfrom
bvolpato:bvolpato/fix-merge-anti-null-keys

Conversation

@bvolpato

@bvolpato bvolpato commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Jira Link

Pending issue creation and linkage. This PR is a draft.

Changes Proposed

Enumerable merge ANTI joins currently stop processing left rows when they reach a NULL join key. Under strict equality, NULL keys do not match and those left rows must survive the ANTI join.

Preserve left NULL keys in all three merge-join advancement paths. Correct the existing ANTI test expectations and add repeated-NULL coverage. The tests also cover empty inputs, NULL keys on the right, and the overload with an additional predicate.

Reproduction

With ascending, NULLS LAST inputs, an equality ANTI join of left [1, 2, NULL] and right [1] returns [2]. The correct result is [2, NULL].

./gradlew :core:test --tests 'org.apache.calcite.runtime.EnumerablesTest'

Validation

  • The updated test class fails in four methods against the baseline runtime.
  • Compiling the changed runtime and running the complete EnumerablesTest class directly passes all 53 enabled tests; one existing test is disabled.
  • Generated EnumerableMergeJoin execution returns [2, NULL] after the fix.
  • ./gradlew autostyleApply and git diff --check pass.
  • Focused runs used freshly compiled changed classes with cached supporting artifacts. Native Gradle test-class compilation on pristine main was blocked by java.io.IOException: No space left on device; the full Gradle build has not been validated locally.

@bvolpato
bvolpato force-pushed the bvolpato/fix-merge-anti-null-keys branch from ca084e2 to 0c3d7fe Compare September 4, 2026 16:37
@sonarqubecloud

sonarqubecloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

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.

1 participant