[
https://issues.apache.org/jira/browse/CALCITE-7938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18145917#comment-18145917
]
Etienne Pelissier commented on CALCITE-7938:
--------------------------------------------
In the description's test, inferring a NONE.[0] collation on the new Project is
valid (it can be proven looking at the plan). The actual issue happens during
Volcano, where collation [0] is expected but EnumerableProjectRule produces
only [].
The underlying issue is therefore not that the inferred collation is invalid,
but rather that Volcano cannot produce an alternative with collation [0]. That
relates to a complex design choice around collations, addressed in CALCITE-2593
and CALCITE-2970.
If I understood correctly, the best approach to fix that underlying issue is to
use ExpandConversionRule in the Volcano phase.
Also, I found another Quidem test (see comment above) that gets the same error
as the description's test, but doesn't contain an Aggregate nor uses
AggregateRemoveRule, which confirms the issue is not centered around that rule.
Finally, adding ExpandConversionRule in Quidem's Volcano phase fixes both of
these tests, and doesn't break any other test.
> AggregateRemoveRule can cause failed planning because of collation mismatch
> ---------------------------------------------------------------------------
>
> Key: CALCITE-7938
> URL: https://issues.apache.org/jira/browse/CALCITE-7938
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Etienne Pelissier
> Assignee: Etienne Pelissier
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.43.0
>
>
> *NB*: I need advices regarding the right fix. See comments.
> Broken quidem test:
> {code}
> !set hep-rules "
> +CoreRules.AGGREGATE_PROJECT_MERGE,
> +CoreRules.AGGREGATE_REMOVE"
> select count(*) as s
> from (values (true, 1), (true, 2)) as t(col1, col2)
> where col1
> group by col2;
> +---+
> | S |
> +---+
> | 1 |
> | 1 |
> +---+
> (2 rows)
> !ok
> {code}
> The query fails with:
> {code}
> There are not enough rules to produce a node with desired properties
> There is 1 empty subset: ... ENUMERABLE.[0]
> {code}
> The issue is reproducible beyond VALUES, I have a JUnit reproducer ready.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)