Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Oct 25, 2024

Conversation

b41sh
Copy link
Member

@b41sh b41sh commented Oct 24, 2024

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

Summary

  • support json_object_delete function
  • support json_object_pick function
  • allow cast variant to map<string, variant>

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

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@b41sh b41sh requested a review from sundy-li October 24, 2024 06:44
@b41sh b41sh changed the title Feat json object delete feat(query): support json_object_delete and json_object_pick function Oct 24, 2024
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Oct 24, 2024
@b41sh b41sh marked this pull request as ready for review October 25, 2024 03:59
@b41sh b41sh enabled auto-merge October 25, 2024 04:00
@b41sh b41sh added this pull request to the merge queue Oct 25, 2024
Merged via the queue into databendlabs:main with commit 78629a5 Oct 25, 2024
75 checks passed
@b41sh b41sh deleted the feat-json-object-delete branch October 25, 2024 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants