Repository navigation
fix: allow reserved keywords as JSON path names (Snowflake, Databricks) - #2913
Open
harryfoster2006 wants to merge 2 commits into
Open
harryfoster2006 wants to merge 2 commits into
harryfoster2006 wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…r AST nodes
The previous commit lets a keyword name the first element after ":" in a
JSON path. A keyword further along the path still threw a ParseException:
SELECT v:a.output, v:a.b.from::INT, v:a[0].from.x[1] FROM t
The expression parser reads v:a.output as a qualified column name, and a
qualified name does not accept a keyword as a part. JsonPathElement now
also looks ahead with isJsonPathWithKeywordAfterDot(), which walks the
identifiers, dots and [...] subscripts of the path and reports whether a
keyword follows a ".". If so, JsonPathKeyword parses the path, with a new
JsonPathStep production taking a keyword after "." as an element name.
isKeywordJsonPathName() shares its keyword test with it through
isKeywordWord(). A word followed by "(" stays a function call, and
t.output outside a JSON path is still rejected.
JsonPathKeyword also left the last step or cast of a path without an AST
node, for example the cast in v:select::INT or v:from::INT + 1. It linked
the previous element before building each step, so the one built last was
never linked. ASTNodeCoverageTest did not notice, as it only walks the SQL
resources. Each step and cast is now linked where it is built, and the
keyword-path cases are added to testStatementsTheCorpusLacks.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
sethdragos
approved these changes
Nov 11, 2026
This branch has not been deployed
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 a ParseException on JSON paths whose element names are reserved keywords. For example:
Produces
error[SqlParseException]: unexpected ":" (DOUBLE_COLON)Path elements after
:were parsed as ordinary column names or expressions. Reserved words such as WINDOW, OUTPUT, FROM and SELECT have no identifier token, so the parser threw. After:a name is mandatory, so any word there is a name, reserved or not.Changes
The two grammar sites that read a path element (PrimaryExpression and JsonExpression) now go through a new JsonPathElement production. It looks ahead before choosing how to parse:
Behaviour that stays the same:
AST links
JsonPathKeyword linked the previous element before building each step, so the last step or cast of a path never got an AST node (for example the cast in v:select::INT, or v:from::INT + 1). ASTNodeCoverageTest didn't catch this because it only walks the SQL test resources. Each step and cast is now linked where it's built.