Skip to content

Fix IN subqueries that return a NULL in the multi-stage engine - #20383

Open
Indian-boult wants to merge 1 commit into
apache:masterfrom
Indian-boult:fix/mse-semi-join-null-keys
Open

Indian-boult wants to merge 1 commit into
apache:masterfrom
Indian-boult:fix/mse-semi-join-null-keys

Conversation

@Indian-boult

Copy link
Copy Markdown
Contributor

Fixes #20382

computeInOperands in ServerPlanRequestUtils now skips null keys before it builds and sorts the IN list, because a null key never matches in a semi join. When no non-null key is left, attachDynamicFilter uses a constant false filter, as it already did for an empty right side.

I added a semi_join_null_keys case to SemiJoins.json with nine queries, one per key type plus two subqueries that return only nulls, all with null handling on. On master all nine fail with the errors in the issue. With the change the full ResourceBasedQueriesTest passes. Spotless, checkstyle and license checks pass on pinot-query-runtime.

The dynamic broadcast semi join turns the keys of its right side into
an IN filter on the left leaf stage. A null key made computeInOperands
throw while it unboxed or sorted the keys, so an IN subquery failed
whenever the subquery returned a null under null handling. A null key
never matches, so it is now left out of the IN list, and a right side
with only null keys gives a constant false filter.

Fixes apache#20382
@codecov-commenter

codecov-commenter commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.21%. Comparing base (4b27e22) to head (12c3cd7).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #20383      +/-   ##
============================================
- Coverage     61.23%   61.21%   -0.02%     
  Complexity        1        1              
============================================
  Files          2793     2793              
  Lines        180530   180544      +14     
  Branches      30232    30237       +5     
============================================
- Hits         110556   110529      -27     
- Misses        60642    60662      +20     
- Partials       9332     9353      +21     
Flag Coverage Δ
java-25 61.21% <100.00%> (-0.02%) ⬇️
temurin 61.21% <100.00%> (-0.02%) ⬇️
unittests 61.21% <100.00%> (-0.02%) ⬇️
unittests1 61.21% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

IN subquery fails in the multi-stage engine when the subquery returns a NULL

2 participants