As title implies, as part of a larger effort to fix a couple of things
related to JSON support,
I'd really like to add support for converting JSON_OBJECT and JSON_ARRAYAGG
calls to the right DB-specific syntax:

https://issues.apache.org/jira/browse/CALCITE-4739

I thought that maybe this functionality would be something that comes out
of "SqlDialect",
or "RelDataTypeSystem", but this doesn't seem to be the case.

Does anyone happen to know what the process would look like roughly to add
this?
Thank you =)

---------------------------

As an aside, after doing some research, it seems nearly every dialect falls
into one of two major categories for JSON syntax.
With SQL-Server having it's own thing because, hey screw us right?
So it shouldn't be super bad I think

-- Postgres & Co (Cockroach, Yugabyte)
SELECT
  "id",
  "name",
  (
    SELECT json_agg(json_build_object(
      'x', CAST(1 AS bigint),
      'foo', CAST('bar' AS varchar)
    ))
  )
FROM "user"
GROUP BY "id", "name"

-- Oracle, MySQL, basically everything that isn't Postgres/SQL-Server
SELECT
    "id",
    "name",
    (
        SELECT JSON_ARRAYAGG(JSON_OBJECT(
            KEY 'x' VALUE 1,
            KEY 'foo' VALUE 'bar'
        ))
    )
FROM "user"
GROUP BY "id", "name";

Reply via email to