[
https://issues.apache.org/jira/browse/CALCITE-2912?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Steven Talbot updated CALCITE-2912:
-----------------------------------
Description:
This seems to stem from
[https://github.com/apache/calcite/blob/d6fb6abd9a17b81a5d8d592860ecd5c2f20ce9b1/core/src/main/java/org/apache/calcite/rel/rules/AbstractMaterializedViewRule.java#L1735]
{quote}.addRuleInstance(this.aggregateProjectPullUpConstantsRule)
{quote}
If commented out, the bug does not occur. Also, when that line is commented
out, all tests in `MaterializationTest.java` pass. The following test
demonstrates the issue (fails on master, passes with line commented out):
{{@Test public void testAggregateMaterializationWithConstantFilter() {}}
{{ checkMaterialize(}}
{{ "select \"deptno\", \"name\", count(*) as c\n"}}
{{ + "from \"depts\" group by \"name\", \"deptno\"",}}
{{ "select \"name\", count(*) as c\n"}}
{{ + "from \"depts\" where \"name\" = 'a_name' group by \"name\"");}}
{{}}}
>From my understanding, the materialization fails to be used because
>`aggregateProjectPullUpConstantsRule` rewrites the Aggregate in `topNode` at
>[https://github.com/apache/calcite/blob/d6fb6abd9a17b81a5d8d592860ecd5c2f20ce9b1/core/src/main/java/org/apache/calcite/rel/rules/AbstractMaterializedViewRule.java#L1743]
> to not include the known constant "name" in its group set, rather groups on
>just deptno and then selects `'a_name'` as a constant.
was:
This seems to stem from
https://github.com/apache/calcite/blob/d6fb6abd9a17b81a5d8d592860ecd5c2f20ce9b1/core/src/main/java/org/apache/calcite/rel/rules/AbstractMaterializedViewRule.java#L1735
{quote}{{.addRuleInstance(this.aggregateProjectPullUpConstantsRule)}}
{quote}
If commented out, the bug does not occur. Also, when that line is commented
out, all tests in `MaterializationTest.java` pass. The following test
demonstrates the issue (fails on master, passes with line commented out):
{quote}{{@Test public void testAggregateMaterializationWithConstantFilter() {}}
{{ checkMaterialize(}}
{{ "select \"deptno\", \"name\", count(*) as c\n"}}
{{ + "from \"depts\" group by \"name\", \"deptno\"",}}
{{ "select \"name\", count(*) as c\n"}}
{{ + "from \"depts\" where \"name\" = 'a_name' group by \"name\"");}}
{{}}}
{quote}
>From my understanding, the materialization fails to be used because
>`aggregateProjectPullUpConstantsRule` rewrites the Aggregate in `topNode` at
>https://github.com/apache/calcite/blob/d6fb6abd9a17b81a5d8d592860ecd5c2f20ce9b1/core/src/main/java/org/apache/calcite/rel/rules/AbstractMaterializedViewRule.java#L1743
> to not include the known constant "name" in its group set, rather groups on
>just deptno and then selects `'a_name'` as a constant.
> MaterializedViewAggregateRule.pushFilterToOriginalViewPlan fails to use valid
> materialization given query with certain kinds of filter constants
> ------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-2912
> URL: https://issues.apache.org/jira/browse/CALCITE-2912
> Project: Calcite
> Issue Type: Bug
> Reporter: Steven Talbot
> Priority: Major
>
> This seems to stem from
> [https://github.com/apache/calcite/blob/d6fb6abd9a17b81a5d8d592860ecd5c2f20ce9b1/core/src/main/java/org/apache/calcite/rel/rules/AbstractMaterializedViewRule.java#L1735]
> {quote}.addRuleInstance(this.aggregateProjectPullUpConstantsRule)
> {quote}
> If commented out, the bug does not occur. Also, when that line is commented
> out, all tests in `MaterializationTest.java` pass. The following test
> demonstrates the issue (fails on master, passes with line commented out):
> {{@Test public void testAggregateMaterializationWithConstantFilter() {}}
> {{ checkMaterialize(}}
> {{ "select \"deptno\", \"name\", count(*) as c\n"}}
> {{ + "from \"depts\" group by \"name\", \"deptno\"",}}
> {{ "select \"name\", count(*) as c\n"}}
> {{ + "from \"depts\" where \"name\" = 'a_name' group by \"name\"");}}
> {{}}}
> From my understanding, the materialization fails to be used because
> `aggregateProjectPullUpConstantsRule` rewrites the Aggregate in `topNode` at
> [https://github.com/apache/calcite/blob/d6fb6abd9a17b81a5d8d592860ecd5c2f20ce9b1/core/src/main/java/org/apache/calcite/rel/rules/AbstractMaterializedViewRule.java#L1743]
> to not include the known constant "name" in its group set, rather groups on
> just deptno and then selects `'a_name'` as a constant.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)