databendlabs / databend

๐——๐—ฎ๐˜๐—ฎ, ๐—”๐—ป๐—ฎ๐—น๐˜†๐˜๐—ถ๐—ฐ๐˜€ & ๐—”๐—œ. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.85k stars 750 forks source link

feat(query): support `json_object_delete` and `json_object_pick` function #16682

Closed b41sh closed 3 weeks ago

b41sh commented 3 weeks ago

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

for example

MySQL [(none)]> SELECT json_object_delete('{"a":1,"b":2,"d":4}'::variant, 'a', 'c');
+--------------------------------------------------------------+
| json_object_delete('{"a":1,"b":2,"d":4}'::VARIANT, 'a', 'c') |
+--------------------------------------------------------------+
| {"b":2,"d":4}                                                |
+--------------------------------------------------------------+
1 row in set (0.167 sec)

MySQL [(none)]> SELECT json_object_pick('{"a":1,"b":2,"d":4}'::variant, 'a', 'c');
+------------------------------------------------------------+
| json_object_pick('{"a":1,"b":2,"d":4}'::VARIANT, 'a', 'c') |
+------------------------------------------------------------+
| {"a":1}                                                    |
+------------------------------------------------------------+
1 row in set (0.046 sec)

MySQL [(none)]> select '{"k1":"v1","k2":"v2"}'::Variant a, a::Map(String, String) b, b::Variant = a;
+-----------------------+-----------------------+----------------+
| a                     | b                     | b::VARIANT = a |
+-----------------------+-----------------------+----------------+
| {"k1":"v1","k2":"v2"} | {'k1':'v1','k2':'v2'} |              1 |
+-----------------------+-----------------------+----------------+
1 row in set (0.051 sec)

fixes: #[Link the issue here]

Tests

Type of change


This change isโ€‚Reviewable