Ganesha S created SPARK-59728:
---------------------------------

             Summary: Keep canonical JSON_ARRAY SQL on the direct grammar path
                 Key: SPARK-59728
                 URL: https://issues.apache.org/jira/browse/SPARK-59728
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 4.4.0
            Reporter: Ganesha S


SPARK-58729 made `JsonObjectExpr.sql` always render an explicit ON NULL clause 
so a resolved built-in's canonical SQL reparses on the direct JSON_OBJECT 
grammar path instead of through routine resolution (where a same-named 
temp/persistent function could shadow it). JsonArray has the same latent gap 
but was left unchanged: JsonArray.sql omits its default ABSENT ON NULL clause, 
so a resolved built-in renders clause-free SQL that reparses as a 
routine-resolvable call.

With a shadowing routine on the path:
 - json_array(1) (user text, clause-free) routes and is shadowed — intended.
- JsonArray(...).sql renders JSON_ARRAY(1) (clause-free), which likewise 
reparses to the shadowable routine rather than the built-in, so the canonical 
SQL of a resolved built-in does not round-trip to the same built-in.

The fix is to render an unambiguous direct-path marker (e.g. always emit the ON 
NULL clause) in JsonArray.sql, mirroring JsonObjectExpr, so a resolved 
JSON_ARRAY built-in round-trips to the built-in. There is a TODO at 
JsonObjectExpr.sql pointing here.

Notes / scope:
- Parse-time routing and shadowing of user-typed queries is unchanged; only 
.sql rendering is affected.
 - Column names for unaliased expressions derive from .sql (toPrettySQL), so 
this makes every default-behavior json_array column name carry an explicit 
clause (e.g. JSON_ARRAY(1 ABSENT ON NULL)). Golden files 
(sql-expression-schema.md, json-functions.sql.out) will need regeneration.
- This is a consistency-with-JSON_OBJECT / round-trip-fidelity change rather 
than a clear bug fix, and it shares the universal shadowable-built-in behavior 
— weigh the column-name noise when deciding whether to proceed.
- Distinct from SPARK-59243, which is about splicing nested constructors 
reached through routed/qualified input calls (carrying FORMAT JSON intent 
through resolution), not .sql rendering



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to