Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.21.0
-
None
-
None
Description
The impacted test is testAggregateMaterializationOnCountDistinctQuery1
The test defines materialized view for the following SQL:
select deptno, empid, salary from emps group by deptno, empid, salary
In practice, the optimizer might be able to tell that empid is a unique key, thus it could understand the grouping is not needed.
However, when it defines a materialized view, it loses uniqueness information, so it declares the view as
select deptno, empid, salary from emps
and the uniqueness is not there.
org.apache.calcite.materialize.MaterializationService.DefaultTableFactory should probably compute metadata (e.g. unique keys, something else?) and propagate it to the materialized view.