Repository navigation
feat(semantic): transpile SQL to dialect entries - #553
Merged
Merged
Conversation
mmotoyama
force-pushed
the
feat/semantic/transpile-dialect-entries
branch
2 times, most recently
from
October 23, 2026 08:50
a59f39c to
8eac09d
Compare
feixufeixu
reviewed
Oct 23, 2026
feixufeixu
left a comment
Collaborator
There was a problem hiding this comment.
The three required comments need changes before this merges. The other two are optional.
feixufeixu
approved these changes
Oct 23, 2026
feixufeixu
left a comment
Collaborator
There was a problem hiding this comment.
Approving. Please apply the required comments before you merge.
Fixes b/573773536. When `--transpile` translates a field or metric expression to BigQuery SQL, `transpileModel` previously wrote the result only to the in-memory `expression` field and skipped `ANSI_SQL` expressions. This meant serialized models lost the translated BigQuery SQL, and `ANSI_SQL` expressions that wrap column names in double quotes (`"orders"."amount"`, which BigQuery reads as string literals) were left untranslated. This PR updates SQL translation in three ways: - Store translated SQL as a `BIGQUERY` entry in `dialects` (and set `stringForm` to `false` so bare-string expressions expand into a `dialects` list when serialized) rather than overwriting `expression`. Because translated SQL now lives in `dialects`, `validateBigQueryMetrics` and `measureProblem` in `validate.ts` read `expressionForDialect(metric, 'BIGQUERY')` before falling back to `metric.expression`. - Translate `ANSI_SQL` expressions that double-quote column names when no `BIGQUERY` entry is present, in addition to vendor-only expressions. `hasDoubleQuotedColumn` detects double-quoted column names by comparing how the SQL parser reads the expression in `ANSI_SQL` (where both `"..."` and `` `...` `` are quoted column identifiers) versus `BIGQUERY` (where only `` `...` `` is). - Align `POLYGLOT_DIALECTS` with `PARSER_DIALECTS` in `sql_parser.ts`, adding `SPANNER` (as BigQuery), `ALLOYDB` (as PostgreSQL), and `SQLSERVER` (as T-SQL), and removing dialect names the loader no longer accepts.
mmotoyama
force-pushed
the
feat/semantic/transpile-dialect-entries
branch
from
October 23, 2026 23:56
8eac09d to
22de641
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.
Fixes b/573773536.
When
--transpiletranslates a field or metric expression toBigQuery SQL,
transpileModelpreviously wrote the result only tothe in-memory
expressionfield and skippedANSI_SQLexpressions.This meant serialized models lost the translated BigQuery SQL, and
ANSI_SQLexpressions that wrap column names in double quotes(
"orders"."amount", which BigQuery reads as string literals) wereleft untranslated.
This PR updates SQL translation in three ways:
BIGQUERYentry indialects(and setstringFormtofalseso bare-string expressions expand into adialectslist when serialized) rather than overwritingexpression. Because translated SQL now lives indialects,validateBigQueryMetricsandmeasureProbleminvalidate.tsread
expressionForDialect(metric, 'BIGQUERY')before fallingback to
metric.expression.ANSI_SQLexpressions that double-quote column nameswhen no
BIGQUERYentry is present, in addition to vendor-onlyexpressions.
hasDoubleQuotedColumndetects double-quoted columnnames by comparing how the SQL parser reads the expression in
ANSI_SQL(where both"..."and`...`are quoted columnidentifiers) versus
BIGQUERY(where only`...`is).POLYGLOT_DIALECTSwithPARSER_DIALECTSinsql_parser.ts, addingSPANNER(as BigQuery),ALLOYDB(asPostgreSQL), and
SQLSERVER(as T-SQL), and removing dialectnames the loader no longer accepts.