Repository navigation
Conversation
sqlmesh macro variables such as @start_dt tokenized as TSQL-style identifiers and parsed as columns. Trino now emits DAt for @name (not @name( calls), so the parser builds Parameter { style: At }. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019snAi4ViWsw4dALcjcASho
…tion Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019snAi4ViWsw4dALcjcASho
Member
Author
|
Closing this without merging. sqlmesh macro parsing doesn't belong in the polyglot fork, so kuma's query rewriter will normalize Trino Generated by Claude Code |
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.
What
In the Trino dialect,
@namenow tokenizes asDAt+ name, so the parser buildsExpression::Parameter { style: ParameterStyle::At, name: Some("name") }, with the name's case preserved. The generator writes it back as@name.@name((a sqlmesh macro function call such as@each(...)) is unchanged: it stays aVaridentifier and still round-trips as@NAME(...).Why
Today every dialect turns
@wordinto a TSQL-style@variableidentifier, so in Trino a sqlmesh macro variable like@start_dtparses as a column. Column extraction on multi-table queries then fails with an ambiguous column reference, and lineage reports the macro as unresolved. kuma's query rewriter is about to substitute these macros with a run's time range, which needs them as parameter nodes.How
TokenizerConfig::at_sign_is_parameter(defaultfalse). OnlyTrinoDialectsets it, so every other dialect (TSQL variables, Snowflake@stage, …) tokenizes exactly as before. Note thatDuneDialectreuses Trino's tokenizer config, so Dune gets the same behaviour.at_word_is_calllooks ahead over the word, using the same character set the TSQL identifier scanner consumes, to keep@name(on the old path. Whitespace before(is not treated as a call (markedponytail:).FROM @namenow goes through the existing stage-reference path instead of producing a table named@name.Tests
dialects::trino::tests:SELECT @start_dt FROM tparses to anAtparameter namedstart_dtand round-trips.@some_macro_func('x')still round-trips.cargo test -p polyglot-sql --libpasses (1345 tests).cargo fmt --all --checkis clean.cargo test,custom_clickhouse_parserfailed (missing fixture directory) and so didtpch_transpile_stack(a debug-build stack/hang). Neither involves Trino or@, and CI provides those fixtures.Consumed by opensource-observer/kuma (OSO-6400), which will re-pin
polyglot-sqlto this PR's merge commit.🤖 Generated with Claude Code
https://claude.ai/code/session_019snAi4ViWsw4dALcjcASho
Generated by Claude Code