-
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
sql: implement JSON{,B}_{OBJECT,}_AGG #19978
Comments
Hi @justinj, is the issue being worked on? I would like to pick it up if possible. |
JSON_OBJECT_AGG requires support of multiple arguments in aggregation function. Related to #10495 |
I think that issue only relates to aggregates which have an argument which is not aggregated (say, for |
I felt that aggregating keys and values separately and combining them finally to build json object seems to be a short-term solution, compared with supporting aggregate functions with secondary arguments. Is it ok to add the secondary arguments support instead? |
@heyihong Sorry if I was unclear - we support all the features required to implement this. What we don't support is having another argument which is not aggregated over, like in |
@justinj According to the hint you gave, the way I could find is to aggregate keys and values separately and then combine them by FinalRendering. If that's the way we should implement, I still doubt that we may need to change the aggregate function system a little bit. The reason is that un like |
Hey @heyihong, I talked to a coworker who knows a bit more about distributed execution - he says there should be a way to do what is needed, but you might need to, worst-case, add a "passthrough" aggregator that does nothing and configure that as the local aggregator step. Does that make any sense? |
Yes, it makes sense. Thanks for the explanation. |
it seems to be stalled for a while, I would like to give it a try if no one minds :) |
Far from it, @C0rWin! We'd love to see this get done. Please follow up with questions if you have them. |
@jordanlewis I've created draft PR #48306 still missing unit test and most likely missed something else, hence would appreciate any suggestions or comments for improvement. More specifically would be glad to get some guidelines regarding unit testing. |
I think this would be an ambitious, but doable first issue.
There's a handful of things that need to happen for this:
JSON object/array. In the case of objects, since their keys need to be
sorted, we would want to do something like push the new keys into a priority
queue (the Go stdlib has a heap implementation). This should be tested
independently from SQL-land. I think this will probably be useful outside of
these aggregates so it should be a somewhat general interface.
These will need be careful to monitor their memory usage, see the
implementation of ARRAY_AGG for reference.
semantics of what is implemented with what Postgres does (handling of NULL,
duplicate keys, etc.).
This needs to happen for the next major release so I'll get to it if nobody is
interested in picking it up.
The text was updated successfully, but these errors were encountered: