Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Aggregate operators may derive row types with duplicate column names. The reason is that the column names for grouping sets columns and aggregation columns might be generated automatically, but we do not check whether the column name already exists in the same row.
This condition may appear e.g. in the following plan:
Aggregate (f1, sum(f1)) Union Aggregate (x, sum(x)) ... Aggregate (x, sum(x)) ...
where f1 is the column with the result of sum(x).
Calcite derives the row schema for the aggregation column sum(f1) automatically. The generated name is f1 ('f' of function, '1' of the position in the tuple), which is the same one that the first column has; however, Calcite is not verifying if the autogenerated name was already in the tuple or not. This patch checks if the name already exists, and while it does, it generates a new column name.