feat: add json_path_match udf (#4864)

* add json_path_match udf

* sql tests for json_path_match

* fix clippy & comment

* fix null value behavior

* added null tests

* adjust function's behavior on nulls

* update test cases

* fix null check of json
This commit is contained in:
Kaifeng Zheng
2024-10-25 11:13:34 +08:00
committed by GitHub
parent e328c7067c
commit 4e9c251041
4 changed files with 277 additions and 0 deletions

View File

@@ -6,3 +6,19 @@ SELECT json_path_exists(parse_json('{"a": 1, "b": 2}'), '$.c');
SELECT json_path_exists(parse_json('[1, 2]'), '[0]');
SELECT json_path_exists(parse_json('[1, 2]'), '[2]');
SELECT json_path_exists(parse_json('[1, 2]'), 'null');
SELECT json_path_exists(parse_json('null'), '$.a');
--- json_path_match ---
SELECT json_path_match(parse_json('{"a": 1, "b": 2}'), '$.a == 1');
SELECT json_path_match(parse_json('{"a":1,"b":[1,2,3]}'), '$.b[0] > 1');
SELECT json_path_match(parse_json('{"a":1,"b":[1,2,3]}'), '$.b[1 to last] >= 2');
SELECT json_path_match(parse_json('{"a":1,"b":[1,2,3]}'), 'null');
SELECT json_path_match(parse_json('null'), '$.a == 1');