Support typed array literals ARRAY<T>[...] - #9
Merged
moshap-firebolt merged 1 commit intoAug 20, 2026
Conversation
GoogleSQL/BigQuery allows an array literal to declare its element type in angle brackets before the elements, e.g. `ARRAY<INT64>[1, 2, 3]` (analogous to the already-supported typed struct literal `STRUCT<...>(...)`). Previously this mis-parsed as `ARRAY < T > [..]` (an identifier, comparisons and a subscript). - Add an `element_type: Option<DataType>` field to the `Array` expression node, `None` for untyped `[..]` / `ARRAY[..]`. `Display` renders `ARRAY<T>[...]` when set. - Parse `ARRAY <element_type> [ ... ]` when a new `supports_array_typed_literal` dialect flag is set (BigQuery), reusing the data-type parser (so nested `ARRAY<STRUCT<...>>` / `ARRAY<ARRAY<...>>` element types and empty `ARRAY<INT64>[]` all work). Untyped arrays are unchanged. - Test `parse_typed_array_literal` in `tests/sqlparser_bigquery.rs` covers the round-trip and the recorded element type. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b346f24. Configure here.
| { | ||
| self.expect_token(&Token::Lt)?; | ||
| let (element_type, trailing_bracket) = self.parse_data_type_helper()?; | ||
| self.expect_closing_angle_bracket(trailing_bracket)?; |
There was a problem hiding this comment.
Unmatched angle bracket is swallowed
Low Severity
The typed array path calls expect_closing_angle_bracket and drops its return value. When that helper consumes >>, the leftover > is never reported, so an extra closing bracket is accepted and the literal still parses. Typed STRUCT literals check this leftover flag and error instead.
Reviewed by Cursor Bugbot for commit b346f24. Configure here.
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.


GoogleSQL/BigQuery allows an array literal to declare its element type in angle brackets before the elements, e.g.
ARRAY<INT64>[1, 2, 3](analogous to the already-supported typed struct literalSTRUCT<...>(...)). Previously this mis-parsed asARRAY < T > [..]— an identifier, comparisons and a subscript — which surfaced downstream asColumn 'array' does not exist.Changes
element_type: Option<DataType>field to theArrayexpression node (Nonefor untyped[..]/ARRAY[..]).DisplayrendersARRAY<T>[...]when set, so typed literals round-trip.ARRAY <element_type> [ ... ]when a newsupports_array_typed_literaldialect flag is set (BigQuery), reusing the data-type parser — so nestedARRAY<STRUCT<...>>/ARRAY<ARRAY<...>>element types and emptyARRAY<INT64>[]all work. Untyped arrays are unchanged.Tests
tests/sqlparser_bigquery.rs::parse_typed_array_literal— round-trips scalar / empty / nested-struct / nested-array element types, and asserts the recordedelement_type(andNonefor untyped arrays).Note:
ARRAY<ARRAY<...>>is accepted at the grammar level (valid GoogleSQL); the arrays-of-arrays restriction is a BigQuery semantic rule enforced downstream, consistent with the parser's permissive design.Note
Cursor Bugbot is generating a summary for commit b346f24. Configure here.