fix(snowflake/parser): optional FETCH noise words + TOP count must not consume infix *#297
Merged
Conversation
…t consume infix * (bytebase db-driver gaps)
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.
Fix
Two Snowflake grammar regressions vs legacy ANTLR + official docs, found by the bytebase cutover differential (db/snowflake LIMIT-rewriter yaml):
parseLimitOffsetFetchrequiredFETCH {FIRST|NEXT} n {ROW|ROWS} ONLYin full; all noise words are optional per docs + legacy (FETCH 123,OFFSET 12 FETCH 123now parse). FetchClause Loc.End = last consumed token.*: TOP count used parseExpr, soSELECT TOP 125 * FROM tlexed125 *as multiplication. NewparseTopCount()accepts a single primary (number / $var / parenthesized) and never consumes infix operators.Tests
8 new parser tests (bare/partial FETCH forms incl. Loc-span, TOP star + regression + negatives) + 3 deparse round-trips. Full
go test ./snowflake/... -count=1green incl. corpus. Orchestrator verified on a fresh checkout of8170c3e9.🤖 Generated with Claude Code