Description
CALCITE-828 introduced the usage of RelBuilder in RelFieldTrimmer. In Hive, we are hitting an issue in RelFieldTrimmer with the following query:
SELECT a FROM T1 GROUP BY a GROUPING SETS (a);
The problem is that the indicator boolean in the Aggregate operator is set to true, as grouping sets are present. In particular, the plan is the following:
HiveAggregate(group=[{0}] indicator=[true]) HiveProject(a=[$0]) HiveTableScan(table=[[default.t1]])
However, RelFieldTrimmer will remove the indicator columns, as the number of GroupingSets is <1. This creates a mismatch in the number of columns that results in assertion error. By the definition of the trim function over an Aggregate in RelFieldTrimmer, indicator columns should not be removed.
PS. I tried to reproduce the issue in Calcite using the following query:
select ename, grouping(ename) from emp group by ename, grouping sets (ename)
But I could not, as Calcite infers directly the constant value for the grouping column.
Attachments
Issue Links
- blocks
-
HIVE-12186 Upgrade Hive to Calcite 1.5
- Closed
- is broken by
-
CALCITE-828 Use RelBuilder in rules rather than type-specific RelNode factories
- Closed