maropu commented on a change in pull request #27759: [SPARK-31008][SQL]Support 
json_array_length function
URL: https://github.com/apache/spark/pull/27759#discussion_r388010199
 
 

 ##########
 File path: sql/core/src/test/resources/sql-tests/inputs/json-functions.sql
 ##########
 @@ -58,5 +58,16 @@ select schema_of_json('{"c1":01, "c2":0.1}', 
map('allowNumericLeadingZeros', 'tr
 select schema_of_json(null);
 CREATE TEMPORARY VIEW jsonTable(jsonField, a) AS SELECT * FROM VALUES ('{"a": 
1, "b": 2}', 'a');
 SELECT schema_of_json(jsonField) FROM jsonTable;
+
+-- json_array_length
+select json_array_length('');
+select json_array_length('[]');
+select json_array_length('[1,2,3]');
+select json_array_length('[[1,2],[5,6,7]]');
+select json_array_length('[{"a":123},{"b":"hello"}]');
+select json_array_length('[1,2,3,[33,44],{"key":[2,3,4]}]');
+select json_array_length('{"key":"not a json array"}');
 
 Review comment:
   Does this function need to be array-specific? Yea, I know this is the same 
behaviour with pgSQL. But, `json_length` in mysql is more general one? 
   ```
   mysql> select json_length('[1,2,3]');
   +------------------------+
   | json_length('[1,2,3]') |
   +------------------------+
   |                      3 |
   +------------------------+
   1 row in set (0.01 sec)
   
   mysql> select json_length('{"key":"not a json array"}');
   +-------------------------------------------+
   | json_length('{"key":"not a json array"}') |
   +-------------------------------------------+
   |                                         1 |
   +-------------------------------------------+
   1 row in set (0.00 sec)
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to