Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.15.4, 1.16.2, 1.17.1
Description
FLINK-16205 & FLINK-16206 added the support for the new aggregate functions: JSON_OBJECTAGG & JSON_ARRAYAGG, but has a limitation (which is not documented yet) that cannot be used with other aggregate functions, e.g.,
SELECT f0, count(f1), sum(f2), JSON_OBJECTAGG(f1 VALUE f0) FROM T GROUP BY f0
will raise an internal AssertionError
java.lang.AssertionError: Cannot add expression of different type to set:
set type is RecordType(INTEGER f0, BIGINT NOT NULL EXPR$1, INTEGER EXPR$2, VARCHAR(2000) CHARACTER SET "UTF-16LE" NOT NULL EXPR$3) NOT NULL
expression type is RecordType(INTEGER f0, BIGINT NOT NULL EXPR$1) NOT NULL
set is rel#25:LogicalAggregate.NONE.any.None: 0.[NONE].[NONE](input=HepRelVertex#24,group={0},EXPR$1=COUNT($1),EXPR$2=SUM($2),EXPR$3=JSON_OBJECTAGG_NULL_ON_NULL($1, $0))
expression is LogicalAggregate(group=[{0}], EXPR$1=[COUNT($3)])
LogicalProject(f0=[$0], f1=[$1], f2=[$2], $f3=[JSON_STRING($1)])
LogicalTableScan(table=[[default_catalog, default_database, T]])
because the implementation rule only supports single json agg function
an example case runnning on postgresql:
select b, json_object_agg(a, c), count(*), sum(a) from t1 group by b;
The following improvements include two parts:
1. update current documentation to clarify the limitation
2. expand the implementation to support mixed use with other aggregate functions