ganeshashree opened a new pull request, #60336:
URL: https://github.com/apache/spark/pull/60336

   ### What changes were proposed in this pull request?
   
   When Spark turns a `JSON_ARRAY` expression back into SQL text (its canonical 
`sql`), it now always writes the `ON NULL` clause, including the default 
`ABSENT ON NULL`. Before this change it added a made-up `RETURNING STRING`, and 
only in some cases.
   
   ```sql
   -- canonical SQL of JSON_ARRAY(1)
   -- before: JSON_ARRAY(1 RETURNING STRING)
   -- after:  JSON_ARRAY(1 ABSENT ON NULL)
   ```
   
   Auto-generated column names stay the same (`JSON_ARRAY(1)`).
   
   ### Why are the changes needed?
   
   A `JSON_ARRAY` call with no clauses can be resolved to a user function of 
the same name on the SQL path. So the canonical SQL needs an explicit clause to 
make sure it still means the built-in when parsed again. `JSON_OBJECT` already 
does this with its default `NULL ON NULL`. Using the default `ON NULL` clause 
for `JSON_ARRAY` too makes the two constructors work the same way. It also 
replaces a conditional rule with a simple one: the clause is always written.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. `JSON_ARRAY` has not been released yet.
   
   ### How was this patch tested?
   
   Updated the expected SQL in `JsonArraySuite` and added a test for the 
default, `NULL ON NULL`, and zero-element cases. Ran `JsonArraySuite`, 
`JsonObjectSuite`, `JsonQuerySuite`, `JsonValueSuite`, 
`SparkSessionExtensionSuite` and `GeneratedColumnWriteSuite` locally.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 5.5)
   
   This pull request and its description were written by Isaac.
   


-- 
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