ganeshashree commented on code in PR #58034:
URL: https://github.com/apache/spark/pull/58034#discussion_r4132956426


##########
sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4:
##########
@@ -1486,6 +1486,11 @@ primaryExpression
       (nullBehavior=jsonConstructorNullBehavior ON NULL)?
       (RETURNING returning=dataType)?
       RIGHT_PAREN                                  #jsonArray
+    | JSON_OBJECT LEFT_PAREN (
+        jsonObjectMember (COMMA jsonObjectMember)*

Review Comment:
   Confirmed against the parser: a colon-bearing comma-form argument does bind 
as colon members (e.g. `JSON_OBJECT(v:k, v:x)` parses to the two members `v:k` 
and `v:x`). Since that colon-member reading is the SQL-standard `key : value` 
interpretation and its list is declared first, reordering the alternatives 
would break the common `JSON_OBJECT('a':1, 'b':2)` case. Rather than a 
grammar-level disambiguation with that tradeoff, I've documented the precedence 
and the parenthesization workaround (`JSON_OBJECT((v:k), (v:x))` forces the 
comma form) at the `jsonObjectCommaMember` rule, and added a characterization 
test in `JsonObjectSuite`. Happy to pursue a grammar change instead if you'd 
prefer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to