Skip to content

sql: implement JSON{,B}_{OBJECT,}_AGG #19978

@justinj

Description

@justinj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-builtinsSQL built-in functions and semantics thereof.A-sql-jsonJSON handling in SQL.A-sql-pgcompatSemantic compatibility with PostgreSQLC-enhancementSolution 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.good first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions