v.23.2New Feature
Add JSONArrayLength Function to Return JSON Array Element Count
Add new function JSONArrayLength, which returns the number of elements in the outermost JSON array. The function returns NULL if the input JSON string is invalid. #46631 (李扬).Why it matters
This function provides a simple way to get the length of a JSON array directly within ClickHouse. It helps users quickly determine the size of JSON array data, improving JSON data processing and validation workflows. If the input is not a valid JSON array, the function returns NULL, ensuring safe handling of invalid JSON strings.How to use it
Use theJSONArrayLength function by passing a JSON-formatted string representing the array as its argument. It returns an integer count of the outermost array elements or NULL if the JSON is invalid. Example usage:SELECT JSONArrayLength('[1, 2, 3, 4]');This will return 4.