You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "advancedxy (via GitHub)" <gi...@apache.org> on 2023/05/15 14:02:15 UTC

[GitHub] [spark] advancedxy commented on pull request #41166: [SPARK-40189][SQL] Add `json_array_get` function

advancedxy commented on PR #41166:
URL: https://github.com/apache/spark/pull/41166#issuecomment-1547916306

   > By the way, does Spark have any way to get json array value use specified index. This is a useful function, if we can achieve this requirement without this function, this function maybe unnecessary.
   
   I believe you cloud use get_json_object to archive the same result for `json_array_get`
   ```
   scala> spark.sql("""select get_json_object('[{"a":123},{"b":"hello"}]', "$[0]");""").show
   +------------------------------------------------+
   |get_json_object([{"a":123},{"b":"hello"}], $[0])|
   +------------------------------------------------+
   |                                       {"a":123}|
   +------------------------------------------------+
   
   
   scala> spark.sql("""select get_json_object('[{"a":123},{"b":"hello"}]', "$[1]");""").show
   +------------------------------------------------+
   |get_json_object([{"a":123},{"b":"hello"}], $[1])|
   +------------------------------------------------+
   |                                   {"b":"hello"}|
   +------------------------------------------------+
   ```


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org