Skip to content

fix(bigquery)!: keep raw and adjacent pieces of bytes, typed literals and grantees - #264

Merged
kvlonge merged 1 commit into
mainfrom
fix/bigquery-literal-forms-breaking
Nov 19, 2026
Merged

kvlonge merged 1 commit into
mainfrom
fix/bigquery-literal-forms-breaking

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Why

BigQuery gave one tree for literals written different ways, so formatting, fingerprints and lint could not tell them apart:

  • b'ab', b'a' b'b' and rb'ab';
  • DATE, DATETIME, TIME and TIMESTAMP of a plain, a raw or an adjacent string;
  • JSON, NUMERIC and other self-typed literals of a raw or adjacent string;
  • a GRANT grantee written plain, raw or as adjacent strings.

Changes

  • Breaking (shared tree): Literal gains RawByteString (rb'...') and JoinedBytes (adjacent bytes: joined value and pieces as written). GrantPrincipal gains an optional written: Option<Literal>, set only for a BigQuery grantee written raw or in pieces. Code that matches Literal exhaustively or builds GrantPrincipal by its fields must handle them.
  • BigQuery parser: a date or time typed literal of one plain string stays a literal node; one of a raw or adjacent string, and any other typed literal, is a self-typed cast of the literal as written.
  • Semantics: GROUP BY matching, which already reads r'ab' as 'ab', also reads raw and adjacent bytes as one bytes literal and a raw or adjacent date or time typed literal as the plain one, so these spellings give no new E230. The new bytes kinds type as BYTES and the binary family.

Verification

  • make check-ci passed on the identical tree in fix(bigquery)!: keep raw and adjacent pieces of bytes, typed literals and grantees #263, which this replaces only to mark the commit itself breaking.
  • BigQuery parser cases: each group of spellings gives distinct trees (fails on main, where each group collapses to one tree). The existing raw-bytes case now expects rb'\u{ff}' and b'\xc3\xbf' to differ in the tree.
  • BigQuery E230 cases: raw and adjacent bytes, raw DATE, adjacent DATETIME, raw TIMESTAMP and raw NUMERIC match their plain forms; raw bytes of another value still give E230; rb'\u{ff}' matches b'\xc3\xbf'.
  • Semantics and BigQuery parser library tests pass.

… and grantees

BigQuery gave one tree for literals written different ways: b'ab',
b'a' b'b' and rb'ab'; DATE, DATETIME, TIME and TIMESTAMP of a plain, a
raw or an adjacent string; JSON, NUMERIC and the other self-typed casts
of a raw or adjacent string; and a GRANT grantee as a plain, raw or
adjacent string.

The shared tree gains two literal kinds, raw bytes and adjacent bytes,
each keeping what was written. A typed literal of a raw or adjacent
string is a self-typed cast of that literal, and a grantee written raw
or in pieces records the written literal beside its name.

The GROUP BY match that already treats r'ab' as 'ab' now also reads raw
and adjacent bytes as one bytes literal and a raw or adjacent date or
time typed literal as the plain one, so these spellings give no new
E230. Bytes of the new kinds type as BYTES.

BREAKING CHANGE: sqlquack-syntax adds Literal::RawByteString and
Literal::JoinedBytes, and GrantPrincipal gains a written field, so an
exhaustive match on Literal or a GrantPrincipal struct literal no longer
compiles.
@kvlonge
kvlonge enabled auto-merge November 18, 2026 23:39
@kvlonge
kvlonge added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 42ce043 Nov 19, 2026
9 checks passed
@kvlonge
kvlonge deleted the fix/bigquery-literal-forms-breaking branch November 19, 2026 01:03
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