Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
v2.3.0
-
None
Description
for queries like:
select sum("count") from (SELECT LSTG_FORMAT_NAME , COUNT AS "count" FROM TEST_KYLIN_FACT GROUP BY "LSTG_FORMAT_NAME" ORDER BY "count" DESC) as a
the expected logical plan after volcano is:
OLAPToEnumerableConverter OLAPLimitRel(ctx=[], fetch=[50000]) OLAPAggregateRel(group=[{}], EXPR$0=[SUM($0)], ctx=[]) OLAPProjectRel(count=[$1], ctx=[]) OLAPSortRel(sort0=[$1], dir0=[DESC], ctx=[]) OLAPAggregateRel(group=[{0}], count=[COUNT()], ctx=[]) OLAPProjectRel(LSTG_FORMAT_NAME=[$3], ctx=[]) OLAPTableScan(table=[[DEFAULT, TEST_KYLIN_FACT]], ctx=[], fields=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]])
however the actual is:
EnumerableLimit(fetch=[50000]) EnumerableAggregate(group=[{}], EXPR$0=[SUM($0)]) EnumerableCalc(expr#0..1=[{inputs}], count=[$t1]) EnumerableSort(sort0=[$1], dir0=[DESC]) EnumerableAggregate(group=[{0}], count=[COUNT()]) OLAPToEnumerableConverter OLAPProjectRel(LSTG_FORMAT_NAME=[$3], ctx=[]) OLAPTableScan(table=[[DEFAULT, TEST_KYLIN_FACT]], ctx=[], fields=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]])
VolcanoPlanner apply OLAPProjectRule to logicalProject,convert child node should use child traitset not current proejct traitset.
If we use current project trait set, the child node trait set is [olap][0 DESC], it will create a new subset but the subset doesn't have any rel. the cost is inf,
so volcanoPlanner choose a the EnumerableAggregate.