Ganesha S created SPARK-59685:
---------------------------------

             Summary: Preserve built-in ownership in the canonical SQL of 
clause-free SQL/JSON functions
                 Key: SPARK-59685
                 URL: https://issues.apache.org/jira/browse/SPARK-59685
             Project: Spark
          Issue Type: Sub-task
          Components: SQL
    Affects Versions: 4.4.0
            Reporter: Ganesha S


AstBuilder routes a clause-free JSON function call through function resolution 
so a same-named routine on the SQL PATH can shadow it (SPARK-59144). But these 
built-ins' canonical Expression.sql drops default-valued clauses, so a call 
that is the built-in only because of a default clause renders clause-free SQL:
{code:java}
JSON_VALUE(j, p RETURNING STRING)   -- built-in (clause present)
  .sql  ==>  JSON_VALUE(j, p)        -- clause-free: routes on reparse{code}
Reparsed under a shadowing PATH (or a stored view's frozen PATH), that 
rendering binds the routine instead of the built-in, silently changing the 
result and possibly the schema.

Fix: when a rendering would otherwise be clause-free, emit the default clause 
(RETURNING STRING, or FALSE ON ERROR for JSON_EXISTS) so canonical SQL reparses 
back to the built-in. Auto-generated column names render the clean form via 
`usePrettyExpression`, so the round-trip-only clause never leaks into display 
names.

Deferred from SPARK-59144 review (thread on AstBuilder.scala:4210).



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