Adding support for IS JSON & IS NOT JSON#2256
Open
LucaCappelletti94 wants to merge 2 commits intoapache:mainfrom
Open
Adding support for IS JSON & IS NOT JSON#2256LucaCappelletti94 wants to merge 2 commits intoapache:mainfrom
IS JSON & IS NOT JSON#2256LucaCappelletti94 wants to merge 2 commits intoapache:mainfrom
Conversation
Introduce AST and parser support for IS JSON predicates, including optional VALUE/SCALAR/ARRAY/OBJECT and WITH/WITHOUT UNIQUE [KEYS] modifiers. Gate parsing by dialect capability, enable Generic/ANSI/PostgreSQL/Oracle, update IS diagnostic hints accordingly, and include parser-side regression coverage. Also apply parser-only control-flow cleanups to keep strict clippy (-D warnings) green.
Add integration coverage for supported IS JSON forms and unsupported-dialect failures for both IS JSON and IS NOT JSON. Tighten malformed-case assertions with token-specific diagnostics, including junk tails and duplicate WITH/WITHOUT UNIQUE KEYS clauses.
55d8e29 to
3014f8c
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.
This PR adds support for the SQL/JSON predicate syntax
expression IS [NOT] JSON [VALUE|SCALAR|ARRAY|OBJECT] [WITH|WITHOUT UNIQUE [KEYS]], aligning with the SQL/JSON testing syntax documented by PostgreSQL (JSON Functions and Operators, Table 9.50) and Oracle (SQL/JSON Conditions IS JSON and IS NOT JSON).Implementation-wise, it introduces
Expr::IsJsonplusJsonPredicateTypeandJsonKeyUniquenessin the AST, parses the full optional modifier chain, and gates support behind a new dialect capability (supports_is_json_predicate()) enabled for Generic, ANSI, PostgreSQL, and Oracle so unsupported dialect behavior and hints remain explicit. I have included ANSI as this method in theory was introduced there in 2016.We also accept optional
KEYS(canonicalizing to include it on display) and added coverage for bothIS JSONandIS NOT JSON, malformed/junk inputs, and duplicate uniqueness clauses.