Skip to content

Adding support for IS JSON & IS NOT JSON#2256

Open
LucaCappelletti94 wants to merge 2 commits intoapache:mainfrom
LucaCappelletti94:postgres-regression-12
Open

Adding support for IS JSON & IS NOT JSON#2256
LucaCappelletti94 wants to merge 2 commits intoapache:mainfrom
LucaCappelletti94:postgres-regression-12

Conversation

@LucaCappelletti94
Copy link
Contributor

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::IsJson plus JsonPredicateType and JsonKeyUniqueness in 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 both IS JSON and IS NOT JSON, malformed/junk inputs, and duplicate uniqueness clauses.

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.
@LucaCappelletti94 LucaCappelletti94 marked this pull request as ready for review February 27, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant