Good day!
I didn't find the way to aggregate json with jooq.
my schema looks like:
CREATE TABLE IF NOT EXISTS usage (
usage DOUBLE PRECISION NOT NULL,
select query:
SelectQuery select = db.createSelectFrom(Usage.TABLE, Usage.METRIC_FIELD, Usage.ACCOUNT_FIELD, sum(Usage.USAGE_FIELD),
inline(new Timestamp(time_from)), inline(new Timestamp(time_to)), Usage.UNIT_FIELD, Usage.DATA_FIELD,
groupConcat(Usage.EVENTS_FIELD));
what at the end corresponds to the query:
select
"metric",
"account",
sum("usage"),
timestamp '1970-01-01 00:00:00.0',
timestamp '2019-08-22 05:15:37.0',
"unit",
"data",
array_agg("events")
from "usage"
where "time" between timestamp '1970-01-01 00:00:00.0' and timestamp '2019-08-22 05:15:37.0'
group by
"metric",
"account",
"unit",
"data"
but in fact I need not array_agg("events") but json_agg("events"). Can it be handled by JOOQ?
best,
Oleksii