feat: interval day to second support#183
Draft
gord02 wants to merge 4 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds IntervalDayToSecond support to the substrait-explain text format, covering both parsing (text → protobuf literal/type) and textification (protobuf → canonical text), and updates the documented grammar accordingly.
Changes:
- Adds
interval_daytyped literal parsing/textification using a compact duration-string encoding (e.g.'4d 5s':interval_day,'123456789ns':interval_day) with bounds validation. - Adds
interval_daytype support, including bareinterval_day(unset precision) and parameterizedinterval_day<precision>(0–12). - Extends grammar + tests for roundtrip coverage of the new type and literal behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/literal_roundtrip.rs | Adds a plan-level roundtrip test covering an interval_day literal. |
| src/types_tests.rs | Adds type/literal roundtrip assertions for interval_day and representative literals. |
| src/textify/types.rs | Emits bare interval_day when precision is unset; emits interval_day<precision> when set. |
| src/textify/expressions.rs | Implements IntervalDayToSecond literal textification as a duration string + adds validation tests. |
| src/parser/types.rs | Parses bare interval_day and parameterized interval_day<precision> with bounded precision validation. |
| src/parser/expressions.rs | Parses :interval_day typed string literals into IntervalDayToSecond with bounds/format checks. |
| src/parser/expression_grammar.pest | Adds interval_day to type grammar and introduces interval_day_type. |
| GRAMMAR.md | Documents interval_day typed-literal and type syntax/semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| duration_str: &str, | ||
| span: pest::Span, | ||
| ) -> Result<(&'a str, &'a str), MessageParseError> { | ||
| let digits_start = if term.starts_with('-') { 1 } else { 0 }; |
Collaborator
Author
There was a problem hiding this comment.
This isn't work addressing. I don't think adding + in front of number is a case we should account for.
Comment on lines
+254
to
+256
| interval_day_literal := duration_term (" " duration_term)* | ||
| duration_term := "-"? digit+ ("d" / "s" / "ms" / "us" / "ns" / "ps") | ||
| ``` |
Comment on lines
+893
to
+897
| // An all-zero value at precision 0 collapses to the same "0s" as the | ||
| // all-zero default (precision 6): precision 0 has no subsecond term | ||
| // at all, so there's nothing to distinguish it from the default once | ||
| // days and seconds are also 0. Re-parsing "0s" always yields | ||
| // precision 6, so this specific value does not round-trip. |
462b480 to
b39deaf
Compare
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.
Description
Adds Substrait's IntervalDayToSecond type and literal to the text format, on both the parse and textify sides.
Type of Change
Testing
Related Issues
Closes #177