v.23.4Improvement

Differences Between JSON_VALUE and Spark's get_json_object Functions

Currently, the JSON_VALUE function is similar as spark's get_json_object function, which support to get value from JSON string by a path like '$.key'. But still has something different - 1. in spark's get_json_object will return null while the path is not exist, but in JSON_VALUE will return empty string; - 2. in spark's get_json_object will return a complex type value, such as a JSON object/array value, but in JSON_VALUE will return empty string. #47494 (KevinyhZou).
Enhancement of the JSON_VALUE function to better align with Spark's get_json_object behavior.

Why it matters

This feature aims to clarify and differentiate the behavior of the JSON_VALUE function in ClickHouse compared to Spark's get_json_object. It addresses inconsistencies in handling non-existent JSON paths and complex JSON types, improving predictability and usability when extracting data from JSON strings.

How to use it

Users can continue using the JSON_VALUE(json_string, 'path') function to extract values by JSON path. Note that unlike Spark’s get_json_object, this function returns an empty string if the path does not exist or if the value at the path is a complex type (object/array).