Skip to content

feat: add support for unix_date expression#3141

Merged
andygrove merged 2 commits intoapache:mainfrom
andygrove:feature/unix_date
Jan 16, 2026
Merged

feat: add support for unix_date expression#3141
andygrove merged 2 commits intoapache:mainfrom
andygrove:feature/unix_date

Conversation

@andygrove
Copy link
Member

Summary

  • Adds native Comet support for Spark's unix_date function
  • Converts a date to the number of days since Unix epoch (1970-01-01)
  • Implemented as a cast from Date32 to Int32 since dates are internally stored as days since epoch

Test Plan

  • Added unit tests for basic functionality with random data
  • Added tests for literal dates including epoch and pre-epoch dates
  • Added test for null handling
  • Verified all existing tests pass

Note: This PR was generated with AI assistance.

Closes #3097

Implements native Comet support for Spark's unix_date function, which
converts a date to the number of days since Unix epoch (1970-01-01).

Since dates are internally stored as days since epoch (i32), this is
implemented as a cast from Date32 to Int32.

Closes apache#3097

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@andygrove andygrove marked this pull request as draft January 14, 2026 23:50
@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.89%. Comparing base (f09f8af) to head (5e59985).
⚠️ Report is 848 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #3141      +/-   ##
============================================
+ Coverage     56.12%   59.89%   +3.76%     
- Complexity      976     1414     +438     
============================================
  Files           119      168      +49     
  Lines         11743    15596    +3853     
  Branches       2251     2589     +338     
============================================
+ Hits           6591     9341    +2750     
- Misses         4012     4946     +934     
- Partials       1140     1309     +169     

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

@andygrove andygrove marked this pull request as ready for review January 15, 2026 02:42
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

Thanks @andygrove what about fuzz testing?

@andygrove
Copy link
Member Author

Thanks @andygrove what about fuzz testing?

The test does use the fuzz data generator:

  test("unix_date") {
    val r = new Random(42)
    val schema = StructType(Seq(StructField("c0", DataTypes.DateType, true)))
    val df = FuzzDataGenerator.generateDataFrame(r, spark, schema, 1000, DataGenOptions())

@andygrove andygrove merged commit 5fa1e69 into apache:main Jan 16, 2026
119 checks passed
@andygrove andygrove deleted the feature/unix_date branch January 16, 2026 20:30
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.

[Feature] Support Spark expression: divide_ym_interval

3 participants