sql-parser: only start a map literal when a bracket follows MAP - #37973
Open
def- wants to merge 1 commit into
Open
sql-parser: only start a map literal when a bracket follows MAP#37973def- wants to merge 1 commit into
def- wants to merge 1 commit into
Conversation
`parse_option_map` committed on the `MAP` keyword alone and then demanded
`[`, so a bare `map` in an option-value position was a hard parse error
rather than falling through to the item name it is.
`map` is a legal bare identifier everywhere else — `SELECT "map"` prints
as `SELECT map` and reparses fine — so `AstDisplay` prints an option whose
value is the item name `map` unquoted, and that output failed to reparse:
CREATE SINK s FROM t INTO KAFKA CONNECTION c (TOPIC CONFIG = "map")
prints `TOPIC CONFIG = map` and then fails with "Expected left square
bracket, found right parenthesis".
Look ahead for the bracket instead. The alternative, quoting `map` in
`can_be_printed_bare`, would change the printed form of every `map`
identifier in every position to work around one non-backtracking call
site; the sibling branches of `parse_option_value` all backtrack already.
Found by the sql_roundtrip cargo-fuzz target.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
def-
force-pushed
the
def/fuzz-03-sql-parser
branch
from
July 31, 2026 10:07
c641514 to
f3fff04
Compare
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.
parse_option_mapcommitted on theMAPkeyword alone and then demanded[, so a baremapin an option-value position was a hard parse errorrather than falling through to the item name it is.
mapis a legal bare identifier everywhere else —SELECT "map"printsas
SELECT mapand reparses fine — soAstDisplayprints an option whosevalue is the item name
mapunquoted, and that output failed to reparse:prints
TOPIC CONFIG = mapand then fails with "Expected left squarebracket, found right parenthesis".
Look ahead for the bracket instead. The alternative, quoting
mapincan_be_printed_bare, would change the printed form of everymapidentifier in every position to work around one non-backtracking call
site; the sibling branches of
parse_option_valueall backtrack already.Found by the sql_roundtrip cargo-fuzz target.