fix(dialect): don't parse @@ system variables as macros - #6117
Open
manan28025 wants to merge 1 commit into
Open
manan28025 wants to merge 1 commit into
manan28025 wants to merge 1 commit into
Conversation
The macro parser treated the second @ in @@DATEFIRST as the start of a macro variable, so T-SQL configuration functions like @@DATEFIRST and BigQuery's @@query_label became a MacroVar and the model failed to render with "Unsupported expression type MacroVar". @@name is now parsed as a system variable, the same way the dialect parses it. Signed-off-by: neatninja <manan81140@gmail.com>
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.
Description
Fixes #5601.
In
_parse_macro, the second@of@@DATEFIRSTwas parsed as the start of a macro variable, so system variables like T-SQL's@@DATEFIRST/@@ROWCOUNTand BigQuery's@@query_labelbecame aMacroVar. The model then failed to render withUnsupported expression type MacroVar.@@namecan't be a macro reference, so it's now parsed as a system variable (Parameter(Parameter(...))), the same way sqlglot parses it for these dialects. A single@is still a macro.Test Plan
test_double_at_system_variable_is_not_a_macro(tsql, bigquery, mysql) andtest_double_at_system_variable_in_model, which renders a T-SQL model using@@DATEFIRSTnext to a regular@xmacro. The tsql, bigquery and model tests fail on main. MySQL already worked, since it tokenizes@@session...differently.Checklist
make styleand fixed any issuesmake fast-test) (ran the tests/core fast and slow suites, see above)git commit -s) per the DCO