Skip to content

Fix physical distinctness expression nullability - #24244

Open
blinding-pixels wants to merge 1 commit into
apache:mainfrom
blinding-pixels:agent/fix-distinctness-nullability
Open

Fix physical distinctness expression nullability#24244
blinding-pixels wants to merge 1 commit into
apache:mainfrom
blinding-pixels:agent/fix-distinctness-nullability

Conversation

@blinding-pixels

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

When aggregate CSE extracts a repeated truth check, the logical and physical plans assign different nullability metadata to it, causing planning to fail. Since these truth checks always return either true or false, the physical plan should mark them as non-nullable.

What changes are included in this PR?

This PR updates physical BinaryExpr nullability so IS DISTINCT FROM and IS NOT DISTINCT FROM are always reported as non-nullable.

It also adds a focused unit-test matrix and a SQL logic regression covering the aggregate CSE path reported in the issue.

Are these changes tested?

Yes. The tests cover both distinctness operators, ordinary equality as a control, and the reported aggregate query.

Formatting, Clippy, focused tests, and the extended workspace test suite all pass.

Are there any user-facing changes?

Yes. Affected queries using repeated truth checks on nullable Boolean values now plan and execute instead of failing with a logical/physical schema mismatch.

There are no public API changes.

@github-actions github-actions Bot added physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt) labels Aug 11, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.99%. Comparing base (a9b61ab) to head (fac096a).

Files with missing lines Patch % Lines
datafusion/physical-expr/src/expressions/binary.rs 78.94% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24244      +/-   ##
==========================================
- Coverage   80.99%   80.99%   -0.01%     
==========================================
  Files        1106     1106              
  Lines      383549   383567      +18     
  Branches   383549   383567      +18     
==========================================
+ Hits       310644   310654      +10     
  Misses      54570    54570              
- Partials    18335    18343       +8     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 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

physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Physical distinctness expressions incorrectly report nullable output

2 participants