Repository navigation
feat(syntax): check the head and option lists of Snowflake statements kept as text - #206
Merged
Merged
Conversation
… kept as text A Snowflake CREATE or ALTER with no structured grammar fell back to raw text and accepted anything. One shared check now reads it before the fallback and refuses what Snowflake refuses: a malformed IF [NOT] EXISTS, a missing or reserved name, an ALTER name with no action after it, a property with no name or value around `=`, a malformed tag list, unbalanced parentheses, RENAME without TO, AS with no body, a reserved keyword used as a name, and a word that needs an operand at the end. The tree stays the same raw text. TAG, STAGE, STREAM and FILE FORMAT creates, which keep their own raw parsers, run the same check.
…AST join aliases as what they are A DELETE USING subquery was a table with an empty name and the query in its hints; it is now a derived table in using_items, as a FROM subquery is, with its alias, column aliases and AS spelling. A semantic view's name was a column node; it is now a table reference, and an explicit AS in its clauses is recorded. On a join with no ON or USING, FIRST or LAST followed by parentheses is the joined table's alias and column aliases, as Snowflake reads it, not a read-order clause.
The check of Snowflake statements kept as text clears 1,327 syntax errors the parser accepted and 5 other contradicted receipts; the list only shrinks. Those statements stay opaque, so no form becomes verified through them. The join form whose FIRST and LAST cases Snowflake reads as table aliases loses its approval until cases with a read-order clause are recorded.
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.
Why
Snowflake CREATE and ALTER statements with no structured grammar stay opaque raw text, and the parser accepted any of them: 1,869 cases with a receipted syntax error. A grammar review also found three trees that misdescribe the SQL.
Changes
IF [NOT] EXISTS, missing or reserved names, an ALTER with no action,=without a name or value, bad tag lists, unbalanced parentheses, RENAME without TO, AS with no body and a dangling operand word. Accepted trees are unchanged.using_items.Verification
Before → after on evidence 2cae594b:
Validated is not parsed. The checked statements stay opaque. Opaque accepts of cases Snowflake parsed stay at 1,920 in 154 forms. The checker counts these as unsatisfied, so none becomes verified. Structured trees for them are left to later grammar work.
sf.query.join.join.syntaxloses its approval. Snowflake read its FIRST/LAST cases as aliases (errno 2003, not 1868), so the old count overstated coverage. It returns when read-order cases are recorded.Across all 61,904 cases, no parsed case is now refused, and accepted trees outside the three fixes are byte-identical. New regression tests cover both changes.
make check-cipassed.