Skip to content

feat: support generic struct literals (coverage C2b) - #21

Open
EpsilonPrime wants to merge 1 commit into
substrait-063-compound-literalsfrom
substrait-063-struct-literals
Open

feat: support generic struct literals (coverage C2b)#21
EpsilonPrime wants to merge 1 commit into
substrait-063-compound-literalsfrom
substrait-063-struct-literals

Conversation

@EpsilonPrime

Copy link
Copy Markdown
Member

Coverage PR C2b (stacked on C2 #20). Implements generic struct literals.

What

Only interval-typed {} literals were handled; a generic struct fell through to i64(0), and the printer stubbed Struct.

  • Parser: new build_struct_literal builds LiteralType::Struct (fields recursively via build_constant). Both the non-interval type-suffix case and the suffix-less case route to it. Interval {} literals ({y,m}_interval_year_month, {d,s,us}_interval_day_second) are untouched — the type suffix still routes them.
  • Printer: emit {field, field, ...} recursively.

The {} overloading is resolved by dispatch: : → map, interval suffix → interval, otherwise → struct.

Tests

  • test_roundtrip_struct_literal: heterogeneous {1_i32, "hello"} round-trips text→binary→text.
  • Full suite: 52 passed, 1 ignored, fmt clean (intervals still pass).

Remaining in the {} family: C2c — list + empty-list/empty-map literals (need new grammar).

Generic struct literals were parsed to i64(0) (only interval-typed `{}`
literals were handled) and printed as STRUCT_LITERAL_NOT_YET_IMPLEMENTED.

- Parser: add build_struct_literal, routing both the non-interval type-suffix
  case and the suffix-less case to a real LiteralType::Struct (fields built
  recursively via build_constant). Interval `{}` literals are unchanged.
- Printer: emit `{field, field, ...}` recursively.

Adds a text -> binary -> text round-trip test with a heterogeneous struct
`{1_i32, "hello"}`; updates COVERAGE.md.
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.

1 participant