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

   ### What changes were proposed in this pull request?
   
   Since SPARK-59144, a clause-free SQL/JSON constructor call (`JSON_VALUE` / 
`JSON_QUERY` /
   `JSON_EXISTS` / `JSON_ARRAY`) routes through function resolution, so a 
same-named routine on the
   SQL PATH can shadow the built-in. However these built-ins' canonical `sql` 
omits default clauses, so
   a call that is a built-in only because of a default clause renders as 
clause-free SQL; reparsing that
   under a shadowing PATH binds the routine instead of the built-in.
   
   This PR renders the default clause (`RETURNING STRING`, or `FALSE ON ERROR` 
for `JSON_EXISTS`) in
   canonical `sql` so the rendering reparses back to the built-in. A shared 
`RoutedSqlJsonExpression`
   trait lets `usePrettyExpression` keep rendering the clean clause-free form 
for auto-generated column
   names (which are never reparsed), so display names stay unaffected.
   
   ### Why are the changes needed?
   
   Without this, a canonical-SQL round-trip (e.g. persisting and reloading a 
view) can silently rebind a
   built-in SQL/JSON constructor to a user routine that shadows it on the SQL 
PATH, changing results.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, within unreleased master only. Canonical SQL of a clause-free SQL/JSON 
constructor now includes
   its default clause. Auto-generated top-level column names are unchanged; a 
nested constructor's
   generated name now shows `FORMAT JSON`, e.g. `JSON_ARRAY(JSON_ARRAY(1, 2) 
FORMAT JSON, 3)`.
   
   ### How was this patch tested?
   
   New unit tests in `JsonValueSuite` / `JsonQuerySuite` / `JsonExistsSuite` / 
`JsonArraySuite`: each
   asserts that a default-clause constructor's canonical SQL reparses to the 
built-in under a shadowing
   PATH, and that its auto-generated column name stays clean. Golden files were 
regenerated.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8)
   
   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