feat(transcode): round-4 Date(Month) and Date(Year) precision support#318
Merged
Merged
Conversation
Closes the deferred item from PR #316: parse_iso_date_to_days previously only accepted YYYY-MM-DD, even for columns declared Date(Month) or Date(Year). Round-4 widens the parser to accept all three precisions, treating lower-precision inputs as the earliest point in the period: YYYY-MM-DD exact day YYYY-MM first day of the month (1970-02 -> 31) YYYY first day of the year (2000 -> 10_957) Algorithm unchanged (Howard Hinnant civil_to_days). The match on parts.as_slice() lets the parser decide what to default for the missing components without changing the math. ## Tests (5 new + 1 expanded; 13 typed_resolver total) typed_resolver_iso_year_only_parses_to_jan_1 typed_resolver_iso_year_month_parses_to_day_1 typed_resolver_iso_lower_precision_rejects_bad_components -- bad month / bad day / non-numeric / empty year typed_resolver_iso_lower_precision_handles_leap_year_feb -- 2020-02 = day 31 of 2020 = 18_293 since epoch typed_resolver_iso_date_rejects_garbage (expanded) -- adds empty-string + 4-part-input rejection cases ## What's still deferred (round-5 territory) - Strict-mode parser that REFUSES cross-precision inputs (e.g. a column declared Date(Day) rejects a YYYY-only string). Today's permissive default is the right round-1 choice for graceful up-cast; strict-mode lands when a consumer asks. - Date(DateTime) precision -- ISO timestamp parser would need a Timestamp column type, not Date32. Different Arrow plumbing. Verified: cargo test transcode::zerocopy::tests::typed_resolver:: 13/13 pass under query-lite,auth-rls-lite. Clippy clean, fmt clean. Cross-link: PR #316 (round-3 typed-value resolver), PR #313 (round-1 triples_to_batch, where Date(_) was first plumbed).
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
Closes the deferred item from PR #316:
parse_iso_date_to_dayspreviously only acceptedYYYY-MM-DD, even when the column was declaredDate(Month)orDate(Year). Round-4 widens the parser to accept all three precisions, treating lower-precision inputs as the earliest point in the period:YYYY-MM-DDYYYY-MM1970-02→ 31YYYY2000→ 10_957Algorithm itself unchanged (Howard Hinnant
civil_to_days). Thematch parts.as_slice()lets the parser default the missing components without changing the math.Tests (5 new + 1 expanded; 13 typed_resolver total)
typed_resolver_iso_year_only_parses_to_jan_1typed_resolver_iso_year_month_parses_to_day_1typed_resolver_iso_lower_precision_rejects_bad_components— bad month / bad day / non-numeric / empty yeartyped_resolver_iso_lower_precision_handles_leap_year_feb—2020-02= day 31 of 2020 = 18_293 since epochtyped_resolver_iso_date_rejects_garbage(expanded) — adds empty-string + 4-part-input rejection cases13/13 typed_resolver tests pass under
query-lite,auth-rls-lite. Clippy clean, fmt clean.What's still deferred (round-5 territory)
Date(Day)rejects aYYYY-only string). Today's permissive default is the right round-1 choice for graceful up-cast; strict-mode lands when a consumer asks.Timestampcolumn type, notDate32. Different Arrow plumbing.Cross-link
triples_to_batch, whereDate(_)was first plumbed)Test plan
cargo test transcode::zerocopy::tests::typed_resolver— 13/13 passcargo clippy --all-targets --features query-lite,auth-rls-lite -- -D warningscargo fmt --checkGenerated by Claude Code