[CALCITE-7448] Add support for : as a field/item access operator#4844
[CALCITE-7448] Add support for : as a field/item access operator#4844tmater wants to merge 7 commits intoapache:mainfrom
: as a field/item access operator#4844Conversation
|
I might wait until the CI issue is resolved before reviewing this PR. |
|
|
I don't understand Calcite JavaCC code very well, I might need to learn it. If no one reviews it this week, I'll start working on it next week. |
Thank you for taking a look, @caicancai. I agree this is still a fairly complex PR, and I wouldn’t claim to fully understand all of its implications yet. That’s also why I tried to include a wide range of test variations and keep the changes gated behind a conformance config. I’ve organized it into five commits (prior to the CI failures) to make the review easier. If it would help further, I’m happy to split it into 4–5 smaller PRs. |
|
Is the behavior with |



Changes Proposed
This PR adds opt-in support for
:as a field/item access operator behind a newSqlConformance#isColonFieldAccessAllowed()hook. No built-in conformance enables it yet, so the default parser behavior is unchanged.It also refactors postfix parsing so colon field access composes with existing dot and bracket access. That covers cases such as
v:field,v:['field name'],arr[1]:field,obj['x']:nested['y'], and colon access followed by bracket or dot postfixes.To avoid ambiguity when colon field access is enabled,
JSON_OBJECTandJSON_OBJECTAGGmust useVALUEsyntax instead of:or comma-separated key/value shorthand.The Babel parser coverage is updated as well so PostgreSQL-style infix casts still require parentheses before bracket access. For example,
(v::variant)[1]parses as item access on the cast result, whilev::variant[1]remains invalid.Reproduction
Testing
Added parser coverage in
SqlParserTestandBabelParserTestfor valid and invalid colon field access, JSON constructor disambiguation, and::cast interactions.Jira Link
CALCITE-7448