Repository navigation
Closed
Labels
Description
Is your feature request related to a problem?
As part of the RFC to add JSON functions, the json_array function would be useful to construct json objects with arrays.
- META RFC: [META]Add PPL
JSONextended functions support #3027 - PPL RFC: [RFC] Add PPL
JSONextended functions support #3028 - Related Spark PPL PR: Support PPL
JSONfunctions: construction and extraction opensearch-spark#780
What solution would you like?
Tasks to complete:
- Add json_array(scalar_value) that returns an ARRAY object with scalars.
- Add json_array(field) that returns an ARRAY object with values from the field, where field can be a multi-value.
- Add json_array(json_object) that returns an ARRAY object with JSON_OBJECTs.
- Add json_array(json_array) that returns a mult-dimensional ARRAY object.
- Add json_array as part of the json_object construction; json_object(key, value [, key, value]*) -> json_object function, where value can also be a `json_array. see: [FEATURE] Add
json_objectconstructor function to PPL #3208.
### `JSON_ARRAY`
**Description**
`json_array(<value>...)` Creates a JSON ARRAY flattening a list of multi-valued fields.
**Argument type:**
- A \<value\> can be any kind of value such as string, number, boolean, array, or json_object.
**Return type:** ARRAY (Spark ArrayType)
An array of any supported data type for a valid JSON array.
Example:
os> source=people | eval `json_array` = json_array(1, 2, 0, -1, 1.1, -0.11)
fetched rows / total rows = 1/1
+------------------------------+
| json_array |
+------------------------------+
| [1.0,2.0,0.0,-1.0,1.1,-0.11] |
+------------------------------+
os> source=people | eval `json_array_object` = json_object("array", json_array(1, 2, 0, -1, 1.1, -0.11))
fetched rows / total rows = 1/1
+----------------------------------------+
| json_array_object |
+----------------------------------------+
| {"array":[1.0,2.0,0.0,-1.0,1.1,-0.11]} |
+----------------------------------------+
What alternatives have you considered?
N/A
Do you have any additional context?
opensearch-project/opensearch-spark#780 - PR to add feature to opensearch-spark PPL
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][FEATURE] Add json_array constructor function to PPL[/-][+][FEATURE] Add `json_array` constructor function to PPL[/+]LantaoJin commentedon Jun 16, 2025
Resolved by #3559 with Calcite implementation.