Skip to content

Conversation

coderfender
Copy link
Contributor

@coderfender coderfender commented Aug 31, 2025

Which issue does this PR close?

Closes #2233

Rationale for this change

Spark performs lazy evaluation with the coalesce function while comet/ data fusion does not . This causes different behavior when one of the expressions errors out (ex: division by zero) .

What changes are included in this PR?

This change essentially converts spark's coalesce nodes into case statement node (to leverage current comet functionality) . This change is minimal and easy to revert once the upstream datafusion bug is fixed.

How are these changes tested?

Unit tests to ensure lazy evaluation is performed

@coderfender
Copy link
Contributor Author

@andygrove , Please kick off the CI whenever you get a chance

@coderfender coderfender marked this pull request as ready for review August 31, 2025 22:42
@coderfender coderfender force-pushed the lazy_eval_coalesce_case_fallback_statement branch from cd2c3cb to f0055e3 Compare September 1, 2025 21:10
@coderfender
Copy link
Contributor Author

Rebased with main branch .

@coderfender coderfender force-pushed the lazy_eval_coalesce_case_fallback_statement branch from f0055e3 to e0cdb86 Compare September 2, 2025 22:54
@codecov-commenter
Copy link

codecov-commenter commented Sep 2, 2025

Codecov Report

❌ Patch coverage is 72.41379% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.86%. Comparing base (f09f8af) to head (e0cdb86).
⚠️ Report is 446 commits behind head on main.

Files with missing lines Patch % Lines
...ain/scala/org/apache/comet/serde/conditional.scala 70.37% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2270      +/-   ##
============================================
+ Coverage     56.12%   57.86%   +1.73%     
- Complexity      976     1291     +315     
============================================
  Files           119      146      +27     
  Lines         11743    13403    +1660     
  Branches       2251     2378     +127     
============================================
+ Hits           6591     7755    +1164     
- Misses         4012     4385     +373     
- Partials       1140     1263     +123     

☔ View full report in Codecov by Sentry.
📢 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.

@coderfender
Copy link
Contributor Author

@andygrove please take a look whenever you get a chance .

Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

Thanks @coderfender. This is looking good. I will review tomorrow.

@coderfender
Copy link
Contributor Author

Thank you very much @andygrove

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.

COALESCE does not perform lazy evaluation (unlike Spark)
3 participants