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: [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]