-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: implement JSON{,B}_{OBJECT,}_AGG #19978
Copy link
Copy link
Closed
Labels
A-sql-builtinsSQL built-in functions and semantics thereof.SQL built-in functions and semantics thereof.A-sql-jsonJSON handling in SQL.JSON handling in SQL.A-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)E-starterMight be suitable for a starter project for new employees or team members.Might be suitable for a starter project for new employees or team members.good first issue
Description
I think this would be an ambitious, but doable first issue.
There's a handful of things that need to happen for this:
- We need a public interface from pkg/util/json to incrementally construct a
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. - Add the aggregates in aggregate_builtins.go that use these new constructors.
These will need be careful to monitor their memory usage, see the
implementation of ARRAY_AGG for reference. - Test the aggregates in SQL-land. Care should be taken to compare the
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-sql-builtinsSQL built-in functions and semantics thereof.SQL built-in functions and semantics thereof.A-sql-jsonJSON handling in SQL.JSON handling in SQL.A-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)E-starterMight be suitable for a starter project for new employees or team members.Might be suitable for a starter project for new employees or team members.good first issue