-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Support lambdas in json_merge function #17284
Comments
Hi Abhishek
Any advice on getting started on this will be helpful. Thanks |
Thanks Shivam.
@clintropolis @kgyrtkirk In case you have any suggestions. |
Elaboration on third point |
Yes. We should. |
I am planning to create a function like Let me know if you have any suggestions. |
Hi @abhishekagarwal87 what should be result for this ?
If we go by 3, then if array size is different do we copy the extra values? Also want to check if json_merge behavior is expected for array values ? In docs it mentions - "Preserves the rightmost value when there are key overlaps". In that case it should choose option1 and not 2. |
Thanks for raising the PR. If I am interpreting @abhishekagarwal87's proposal correctly, the merge aggregator shouldn't be limited to the ADD, MULT... operations. Users should be able to take in a lambda function and apply the operations according to that. This would ideally involve implementing it via a higher-order function - a function taking another function as an argument. You can look at https://druid.apache.org/docs/latest/querying/math-expr/#apply-functions for existing examples of such methods. |
Description
The
json_merge
function would retain the rightmost key when the leaf elements have the same key. However, in some cases, you may want to aggregate the two results e.g. adding, multiplying, etc. If we can pass a lambda as an argument insidejson_merge
, we need not write custom json functions for doing such aggregations.The text was updated successfully, but these errors were encountered: