-
Notifications
You must be signed in to change notification settings - Fork 268
feat: add support for datediff expression #3145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3145 +/- ##
============================================
+ Coverage 56.12% 59.87% +3.74%
- Complexity 976 1414 +438
============================================
Files 119 168 +49
Lines 11743 15587 +3844
Branches 2251 2589 +338
============================================
+ Hits 6591 9332 +2741
- Misses 4012 4946 +934
- Partials 1140 1309 +169 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| FuzzDataGenerator.generateDataFrame(r, spark, schema, 1000, DataGenOptions()) | ||
| } | ||
|
|
||
| test("datediff") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
Summary
datedifffunctiondatediff(endDate, startDate)= endDate - startDateTest Plan
CometTemporalExpressionSuiteCloses #3087