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

Added basic framework for json_merge_aggr #17339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shigarg1
Copy link
Contributor

Fixes #17284

Description

This PR adds a new function JSON_MERGE_AGGR(,<JSON 1>, <JSON 2> .... ) which performs the aggregation when the leaf elements have the same key.

Currently only two aggregators are added - ADD & MULTIPLY
For Array, it retains the functionality of JSON_MERGE function.

Example

JSON_MERGE_AGGR('ADD', {"key": 2}, {"key":3}) -> {"key":5}
JSON_MERGE_AGGR('MULTIPLY', {"key": {"k2": 2}}, {"key":{"k2":3}}) -> {"key":{"k2":6}}

Retained JSON_MERGE functionality

JSON_MERGE_AGGR('ADD', {"key": [1,2,3]}, {"key":[4,5]}) -> {"key":[1,2,3,4,5]}
JSON_MERGE_AGGR('ADD', {"key": [1,2]}, {"key":3}) -> {"key":3}
JSON_MERGE_AGGR('ADD', [1,2,3], [4,5]) -> [1,2,3,4,5]

Key changed/added classes in this PR
  • json_merge_aggr expression function
  • json_merge_aggr sql function

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support lambdas in json_merge function
1 participant