feat: add support for datediff expression#3145
Merged
Merged
Conversation
Adds native Comet support for Spark's datediff function, which returns the number of days between two dates (endDate - startDate). Closes apache#3087 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3145 +/- ##
============================================
+ Coverage 56.12% 60.02% +3.89%
- Complexity 976 1429 +453
============================================
Files 119 170 +51
Lines 11743 15748 +4005
Branches 2251 2602 +351
============================================
+ Hits 6591 9453 +2862
- Misses 4012 4976 +964
- Partials 1140 1319 +179 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| FuzzDataGenerator.generateDataFrame(r, spark, schema, 1000, DataGenOptions()) | ||
| } | ||
|
|
||
| test("datediff") { |
Contributor
There was a problem hiding this comment.
Tests using dates from leap years would be fun to try. Try this -
datediff( 1900-03-01, 1900-02-27) != datediff(2000-03-01, 2000-02-27)
Member
Author
There was a problem hiding this comment.
Good suggestion! I've added leap year edge case tests:
datediff('1900-03-01', '1900-02-27')= 2 days (1900 was NOT a leap year - divisible by 100 but not 400)datediff('2000-03-01', '2000-02-27')= 3 days (2000 WAS a leap year - divisible by 400)datediff('2004-03-01', '2004-02-28')= 2 days (2004 was a leap year - divisible by 4, not by 100)datediff('2100-03-01', '2100-02-28')= 1 day (2100 will NOT be a leap year - divisible by 100 but not 400)
All tests pass.
Add tests for leap year handling as suggested in review: - 1900 was NOT a leap year (divisible by 100 but not 400) - 2000 WAS a leap year (divisible by 400) - 2004 was a leap year (divisible by 4, not by 100) - 2100 will NOT be a leap year (divisible by 100 but not 400) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
parthchandra
approved these changes
Jan 21, 2026
parthchandra
left a comment
Contributor
There was a problem hiding this comment.
lgtm. pending conflict resolution and ci.
Member
Author
|
Thanks for the review @parthchandra |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
datedifffunctiondatediff(endDate, startDate)= endDate - startDateTest Plan
CometTemporalExpressionSuiteCloses #3087