Skip to content
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

fix: Allow partition value timestamp to be ISO8601 formatted string #622

Merged

Conversation

OussamaSaoudi-db
Copy link
Collaborator

@OussamaSaoudi-db OussamaSaoudi-db commented Jan 6, 2025

What changes are proposed in this pull request?

The delta protocol states that partition value timestamps may be encoded as ISO 8601 formatted strings in addition to the existing format of {year}-{month}-{day} {hour}:{minute}:{second}. Previously, we did not cover the ISO8601 case.

This PR allows kernel to read tables to be partitioned on timestamps with this format.

How was this change tested?

New unit tests are introduces to check the following:

  • ISO 8601 with and without microseconds
  • {year}-{month}-{day} {hour}:{minute}:{second} with and without microseconds
  • unix epoch is 0
  • parsing timestamp ntz from 8601 fails
  • parsing date with no time fails

A new integration test is also introduced to check a table with timestamp partition values is correctly read.

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.49%. Comparing base (c3a868f) to head (71d6de6).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #622      +/-   ##
==========================================
+ Coverage   83.45%   83.49%   +0.04%     
==========================================
  Files          74       74              
  Lines       16877    16919      +42     
  Branches    16877    16919      +42     
==========================================
+ Hits        14084    14127      +43     
  Misses       2135     2135              
+ Partials      658      657       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@scovich scovich left a comment

Choose a reason for hiding this comment

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

Approach LGTM!

@OussamaSaoudi-db
Copy link
Collaborator Author

@zachschuermann The integration test creates a directory time=1971-07-22T03:06:40.000000Z/, which breaks the test for windows. Seems to fail because colon is a reserved character in windows and is not allowed in a filename. I'll disable the test for windows, but lmk if I should handle this differently.

@OussamaSaoudi-db OussamaSaoudi-db changed the title Allow partition value timestamp to be ISO8601 formatted string fix: Allow partition value timestamp to be ISO8601 formatted string Jan 6, 2025
@OussamaSaoudi-db OussamaSaoudi-db marked this pull request as ready for review January 6, 2025 19:46
Copy link
Collaborator

@nicklan nicklan left a comment

Choose a reason for hiding this comment

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

lgtm with one nit, thanks!

let mut timestamp = NaiveDateTime::parse_from_str(raw, "%Y-%m-%d %H:%M:%S%.f");

if timestamp.is_err() && *self == Timestamp {
timestamp = NaiveDateTime::parse_from_str(raw, "%+");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment that %+ means "ISO 8601 / RFC 3339 format"

Copy link
Collaborator

@zachschuermann zachschuermann left a comment

Choose a reason for hiding this comment

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

lgtm!

@OussamaSaoudi-db OussamaSaoudi-db merged commit cbb52a4 into delta-io:main Jan 7, 2025
21 checks passed
@OussamaSaoudi-db OussamaSaoudi-db deleted the partitioned_timestamp_fix branch January 7, 2025 17:35
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.

4 participants