Airblader commented on a change in pull request #16776: URL: https://github.com/apache/flink/pull/16776#discussion_r687676394
########## File path: flink-python/pyflink/table/expression.py ########## @@ -1393,6 +1414,47 @@ def json_exists(self, path: str, on_error: JsonExistsOnError = None) -> 'Express else: return _ternary_op("jsonExists")(self, path, on_error._to_j_json_exists_on_error()) + def json_value(self, + path: str, + returning_type: DataType = None, + on_empty: JsonValueOnEmptyOrError = None, + default_on_empty: Any = None, + on_error: JsonValueOnEmptyOrError = None, + default_on_error: Any = None) -> 'Expression': + """ + Extracts a scalar from a JSON string. + + This method searches a JSON string for a given path expression and returns the value if the + value at that path is scalar. Non-scalar values cannot be returned. By default, the value is + returned as `DataTypes.STRING()`. Using `returningType` a different type can be chosen, with + types with the following type roots being supported: + + * `VARCHAR` + * `BOOLEAN` + * `INTEGER` + * `DOUBLE` + + For empty path expressions or errors a behavior can be defined to either return `null`, + raise an error or return a defined default value instead. + + Examples: + :: + + >>> lit('{"a": true}').json_value('$.a') + >>> lit('{"a": true}').json_value('$.a', DataTypes.BOOLEAN()) + >>> lit('{"a": true}').json_value('lax $.b', \ Review comment: No, it isn't. I'll remove it to make it even more of a unique example. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org