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

   ### What changes were proposed in this pull request?
   
   Treat a JSON null selected by an array index as SQL NULL in both 
`GetJsonObjectEvaluator` and the optimized `MultiGetJsonObjectEvaluator`. Add 
regression tests for root and nested array paths, plus cases that distinguish 
JSON null from the JSON string `"null"`.
   
   ### Why are the changes needed?
   
   `get_json_object('[null,1]', '$[0]')` currently returns the four-character 
string `"null"`. This is inconsistent with object-field lookup, which returns 
SQL NULL for a JSON null, and makes the result indistinguishable from 
extracting the JSON string `"null"`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. An indexed path selecting a JSON null now returns SQL NULL instead of 
the string `"null"`. For example:
   
   ```sql
   SELECT get_json_object('[null,1]', '$[0]');
   -- Before: 'null'
   -- After:  NULL
   ```
   Extracting a JSON string remains unchanged: get_json_object('["null"]', 
'$[0]') returns the string "null". This fixes behavior reported in released 
Spark versions as well as on master.
   ### How was this patch tested?
   Added a regression test in JsonExpressionsSuite covering root and nested 
indexed paths, a JSON string "null", a non-null element, and optimized 
extraction.
   Ran:
   ```build/sbt 'catalyst/testOnly 
org.apache.spark.sql.catalyst.expressions.JsonExpressionsSuite'```
   Result: 102 tests succeeded, 0 failed.
   ### Was this patch authored or co-authored using generative AI tooling?
   Co-authored using OpenAI Codex (GPT-6)
   I reviewed the patch and affirm that this contribution is my original work 
and that I license it under the project's open source license.


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