Skip to content

Conversation

@XuTingjun
Copy link
Contributor

"import org.apache.spark.util.Utils" is never used in HistoryServer.scala

"import org.apache.spark.util.Utils" is never used in HistoryServer.scala
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

the variable named args is never used by other code
@rxin
Copy link
Contributor

rxin commented Jul 2, 2014

Looks like it is not cleanly mergeable. Do you mind fixing that first?

@andrewor14
Copy link
Contributor

Hi @XuTingjun I took care of these as part of my changes in #1280. Would you mind closing this one?

@XuTingjun
Copy link
Contributor Author

it's ok

@rxin
Copy link
Contributor

rxin commented Jul 8, 2014

@XuTingjun Do you mind clicking the close button to close this pull request? We actually don't have the permission to do that.

@XuTingjun XuTingjun closed this Jul 13, 2014
wangyum added a commit that referenced this pull request May 26, 2023
…1284)

* [SPARK-31008][SQL] Support json_array_length function

### What changes were proposed in this pull request?
At the moment we do not have any function to compute length of JSON array directly.
I propose a  `json_array_length` function which will return the length of the outermost JSON array.

- This function will return length of the outermost JSON array, if JSON array is valid.
```

scala> spark.sql("select json_array_length('[1,2,3,[33,44],{\"key\":[2,3,4]}]')").show
+--------------------------------------------------+
|json_array_length([1,2,3,[33,44],{"key":[2,3,4]}])|
+--------------------------------------------------+
|                                                 5|
+--------------------------------------------------+

scala> spark.sql("select json_array_length('[[1],[2,3]]')").show
+------------------------------+
|json_array_length([[1],[2,3]])|
+------------------------------+
|                             2|
+------------------------------+

```
- In case of any other valid JSON string, invalid JSON string or null array or `NULL` input , `NULL` will be returned.
```
scala> spark.sql("select json_array_length('')").show
+-------------------+
|json_array_length()|
+-------------------+
|               null|
+-------------------+
```

### Why are the changes needed?

- As mentioned in JIRA, this function is supported by presto, postgreSQL, redshift, SQLite, MySQL, MariaDB, IBM DB2.

- for better user experience and ease of use.

```
Performance Result for Json array - [1, 2, 3, 4]

Intel(R) Core(TM) i7-9750H CPU  2.60GHz
JSON functions:                           Best Time(ms)   Avg Time(ms)   Stdev(ms)    Rate(M/s)   Per Row(ns)   Relative
------------------------------------------------------------------------------------------------------------------------
json_array_length                                  7728           7762          53          1.3         772.8       1.0X
size+from_json                                    12739          12895         199          0.8        1273.9       0.6X

```

### Does this PR introduce any user-facing change?
Yes, now users can get length of a json array by using `json_array_length`.

### How was this patch tested?
Added UT.

Closes #27759 from iRakson/jsonArrayLength.

Authored-by: iRakson <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>

(cherry picked from commit 71022d7)
ashevchuk123 pushed a commit to mapr/spark that referenced this pull request Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants