Skip to content

fix: preserve NULL semantics in bitwise xor simplification - #24248

Open
lyne7-sc wants to merge 1 commit into
apache:mainfrom
lyne7-sc:fix-xor-nullable-simplification
Open

fix: preserve NULL semantics in bitwise xor simplification#24248
lyne7-sc wants to merge 1 commit into
apache:mainfrom
lyne7-sc:fix-xor-nullable-simplification

Conversation

@lyne7-sc

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Bitwise XOR simplifications cancelled repeated nullable operands, which could incorrectly produce a non-NULL result when the operand was NULL.

For example:

SELECT
  i XOR i,
  (i XOR 7) XOR i,
  i XOR (7 XOR i)
FROM (VALUES (NULL::INT)) AS t(i);

These expressions should all return NULL, but simplification could replace them with 0, 7, and 7.

What changes are included in this PR?

Only cancel repeated XOR operands when the removed operand is non-nullable.

Are these changes tested?

Yes. Added sqllogictests covering results.

Are there any user-facing changes?

Yes. Bitwise XOR expressions with repeated nullable operands now correctly preserve NULLs.

@github-actions github-actions Bot added optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) labels Aug 11, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.01%. Comparing base (918013e) to head (d1a84e7).
⚠️ Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
...imizer/src/simplify_expressions/expr_simplifier.rs 96.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24248      +/-   ##
==========================================
- Coverage   81.06%   81.01%   -0.06%     
==========================================
  Files        1106     1106              
  Lines      381891   384036    +2145     
  Branches   381891   384036    +2145     
==========================================
+ Hits       309578   311121    +1543     
- Misses      54034    54576     +542     
- Partials    18279    18339      +60     

☔ 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

optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants