Repository navigation
fix(sql): a column declares its sub-fields and its script together, as it renders them - #440
Merged
Merged
Conversation
…s it renders them - `Column.sql` renders a column's sub-fields, then its script: `c VARCHAR FIELDS (raw KEYWORD) SCRIPT AS (UPPER(k))`. The grammar read a script OR sub-fields, never both, so that rendering was refused with `')' expected but 'S' found`. - A materialized view renders exactly that column for a string GROUP BY key (UPPER, LOWER, CONCAT, …), which gets a `keyword` sub-field, and re-parses its DDL when it deploys. - The column production now reads `FIELDS (…)`, then an optional `SCRIPT AS (…) [STORED]`, in that order. The shapes that already parsed parse as before; `SCRIPT AS (…) FIELDS (…)`, never rendered, stays refused. Tests: `ColumnFieldsAndScriptSpec` round-trips parse, render, parse for the new shapes (with STORED, COMMENT, DEFAULT) and the four existing ones, and pins the refusal. A DDL row in `GatewayApiIntegrationSpec` creates such a column, reads its computed value and asserts its mapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fupelaqu
force-pushed
the
fix/column-fields-and-script
branch
from
October 21, 2026 09:56
a5fb419 to
58b168a
Compare
fupelaqu
marked this pull request as ready for review
October 21, 2026 12:09
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.
The defect
Column.sqlrenders a column's sub-fields, then its script:c VARCHAR FIELDS (raw KEYWORD) SCRIPT AS (UPPER(k)). The DDL parser refused that rendering with')' expected but 'S' found, because itscolumnproduction read a script OR sub-fields, never both (storedScript | optionalMultiFields). So a table holding such a column did not re-parse.A materialized view renders exactly that column for a string GROUP BY key (UPPER, LOWER, CONCAT, …), which gets a
keywordsub-field, and it re-parses its DDL when it deploys. Such a view was refused at creation.The fix
Parser.columnreadsFIELDS (…), then an optionalSCRIPT AS (…) [STORED], in the orderColumn.sqlrenders them. It builds the sameColumn: the script throughScriptProcessor.fromScript, with the sub-fields beside it.SCRIPT AS (…) FIELDS (…)is never rendered, and stays refused.columnis still alazy valPackratParser, and it tries the same two sub-productions as before.Tests
ColumnFieldsAndScriptSpec(sql, 9 tests). Each row parses a table, renders it (Table.sql) and parses the rendering again. It asserts that the rendering is stable and that the column reads the same (script, STORED, sub-fields, DEFAULT, COMMENT). The rows:SCRIPT AS (…) FIELDS (…), pinned (')' expected but 'F' found).')' expected but 'S' found.GatewayApiIntegrationSpec:CREATE TABLE … (id INT, k KEYWORD, c VARCHAR FIELDS (raw KEYWORD) SCRIPT AS (UPPER(k))), with one documentk = 'ab'. The pipeline computesc = 'AB', and the mapping isc: textwithfields.raw: keyword.')' expected but 'S' found.sql/test: 1922 succeeded, 0 failed (1913 + 9). No existing pin moved, and no existing DDL renders or parses differently.ALTER TABLE … ADD COLUMNshapes are unchanged.Release note
"A column can declare its sub-fields and its script together (
c VARCHAR FIELDS (raw KEYWORD) SCRIPT AS (UPPER(k))), asSHOW TABLErenders it."Recorded, unchanged (pre-existing)
c INT SCRIPT AS (UPPER(k))ando STRUCT SCRIPT AS (UPPER(k))already parse. The fix extends that too STRUCT FIELDS (a KEYWORD) SCRIPT AS (UPPER(k))(PARSE only).SCRIPT AS (…) FIELDS (…)is the combinator's message (')' expected but 'F' found, orend of input expectedinALTER TABLE … ADD COLUMN), and does not name the required order.Verification not run here
core/testand the bridge suites on this branch (the change is insqlonly).headerCheck scalafmtSbtCheck scalafmtCheck test:scalafmtCheck), green.sbt "+ compile"(2.12 and 2.13), green on a tree holding this commit.The materialized-view fix for string GROUP BY keys in extensions needs this change.
🤖 Generated with Claude Code