samuelcolvin commented on issue #7845: URL: https://github.com/apache/datafusion/issues/7845#issuecomment-2073675288
https://github.com/datafusion-contrib/datafusion-functions-json now provides the following methods, are think we're nearly ready for a first release, see https://github.com/datafusion-contrib/datafusion-functions-json/issues/5. * [x] `json_contains(json: str, *keys: str | int) -> bool` - true if a JSON object has a specific key * [x] `json_get(json: str, *keys: str | int) -> JsonUnion` - Get a value from a JSON object by its "path" * [x] `json_get_str(json: str, *keys: str | int) -> str` - Get a string value from a JSON object by its "path" * [x] `json_get_int(json: str, *keys: str | int) -> int` - Get an integer value from a JSON object by its "path" * [x] `json_get_float(json: str, *keys: str | int) -> float` - Get a float value from a JSON object by its "path" * [x] `json_get_bool(json: str, *keys: str | int) -> bool` - Get a boolean value from a JSON object by its "path" * [x] `json_get_json(json: str, *keys: str | int) -> str` - Get any value from a JSON object by its "path", represented as a string * [x] `json_length(json: str, *keys: str | int) -> int` - get the length of a JSON object or array Cast expressions with `json_get` are rewritten to the appropriate method, e.g. ```sql select * from foo where json_get(attributes, 'bar')::string='ham' ``` Will be rewritten to: ```sql select * from foo where json_get_str(attributes, 'bar')='ham' ``` -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
