feat: parse BigQuery JSON string literals as implicit casts - #2488
Merged
manticore-projects merged 1 commit intoAug 19, 2026
Merged
Conversation
isImplicitCastAhead() only fired for DATA_TYPE and DT_ZONE tokens, but
JSON lexes as K_JSON, so BigQuery literals like JSON '{"a": 1}' failed
to parse even though DataType() accepts K_JSON as a data type. Accept
K_JSON when directly followed by a string literal.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
@manticore-projects when you have a moment, could you take a look at this one? It restores BigQuery |
Contributor
|
Thank you very much! |
manticore-projects
merged commit Aug 19, 2026
15e58e9
into
JSQLParser:manticore
2 of 6 checks passed
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.
Problem
BigQuery-style JSON string literals fail to parse on the
manticorebranch:all throw
ParseException: Encountered: <S_CHAR_LITERAL>at the literal afterJSON. These parsed fine before the Pratt-parser rework (e.g. in the 5.4-SNAPSHOT line from late 2025).Cause
isImplicitCastAhead()only treatsDT_ZONEandDATA_TYPEtokens as implicit-cast prefixes.JSONlexes asK_JSON(it is needed as a keyword elsewhere:FORMAT JSON,FOR JSON AUTO, ...), soJSON 'literal'never reachesImplicitCast(), even thoughDataType()already acceptsK_JSONas a data type. Inside function arguments the parser then consumesJSONas a column and fails on the following string literal.Fix
Accept
K_JSONinisImplicitCastAhead()when it is directly followed by a string literal, which is unambiguous with all keyword uses ofJSON:Adds a regression test to
CastExpressionTestcovering the standalone literal and the function-argument case.Validated against the JSQLTranspiler test suite (1042 tests), where this fix resolves 24 BigQuery JSON parse failures without affecting any other test.
🤖 Generated with Claude Code