Skip to content

fix: preserve NULL semantics in log and power simplification - #24247

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

fix: preserve NULL semantics in log and power simplification#24247
lyne7-sc wants to merge 1 commit into
apache:mainfrom
lyne7-sc:fix-log-power-nullable-simplification

Conversation

@lyne7-sc

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

log and power simplifications removed a nullable base expression, which could incorrectly produce a non-NULL result when the base was NULL.

For example:

SELECT log(a, 1.0), power(a, 0.0)
FROM (VALUES (NULL::DOUBLE)) AS t(a);

These expressions should both return NULL, but simplification could replace them with 0.0 and 1.0.

What changes are included in this PR?

only apply these simplifications when the removed base expression is non-nullable.

Are these changes tested?

Yes. Added sqllogictests covering results and plans.

Are there any user-facing changes?

Yes. log and power expressions with nullable bases now correctly preserve NULLs.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Aug 11, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.23077% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.01%. Comparing base (4b48cb0) to head (3a74506).
⚠️ Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/functions/src/math/log.rs 71.42% 0 Missing and 2 partials ⚠️
datafusion/functions/src/math/power.rs 66.66% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24247      +/-   ##
==========================================
- Coverage   81.06%   81.01%   -0.05%     
==========================================
  Files        1106     1106              
  Lines      382252   383982    +1730     
  Branches   382252   383982    +1730     
==========================================
+ Hits       309861   311080    +1219     
- Misses      54083    54561     +478     
- Partials    18308    18341      +33     

☔ 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.

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @lyne7-sc

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

Labels

functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants