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

   ### What changes were proposed in this pull request?
   
   `json_value`, `json_query` and `json_exists` evaluate their `path` argument 
during analysis. A path can be a constant expression that still fails when 
evaluated, for example:
   
   ```sql
   SELECT json_value('{}', element_at(array('$.a'), 0));
   ```
   
   Before this change, the runtime error from evaluating the path (here 
`INVALID_INDEX_OF_ZERO`) leaked out of analysis as-is. Now it is reported as an 
invalid `path` argument:
   
   ```
   [INVALID_PARAMETER_VALUE.EVALUATION_ERROR] The value of parameter(s) `path` 
in `json_value` is invalid:
   the expression "element_at(array($.a), 0)" could not be evaluated.
   ```
   
   The original error is kept as the cause.
   
   ### Why are the changes needed?
   
   The error should name the argument that is wrong and come from analysis, 
like the other path-argument errors these functions already raise (non-foldable 
path, NULL path, wrong type).
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, the error class for this case changes as described above. These 
functions are not released yet, so this does not affect any released Spark 
version.
   
   ### How was this patch tested?
   
   Added a test in `JsonValueSuite` covering all three functions, called both 
unqualified and qualified.
   
   ### 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