[
https://issues.apache.org/jira/browse/CALCITE-3052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16836996#comment-16836996
]
Anton Haidai commented on CALCITE-3052:
---------------------------------------
Other than that, looks like I found two other potential bugs while trying to
reproduce the issue in "MaterializationTest":
h2. Issue 1: target out of range
{code}
@Test public void testPremutationError() {
CalciteAssert.that()
.withMaterializations(
HR_FKUK_MODEL,
"m0",
"select min(\"salary\"), count(*), max(\"salary\"),
sum(\"salary\"), \"empid\" from \"emps\" group by \"empid\"",
"m1",
"select min(\"salary\"), count(*), max(\"salary\"),
sum(\"salary\"), \"deptno\", \"empid\" from \"emps\" group by \"empid\",
\"deptno\""
)
.query(
"select count(*), \"empid\" from \"emps\" group by \"empid\"")
.enableMaterializations(true)
.explainContains("EnumerableTableScan(table=[[hr, m0]])")
.sameResultWithMaterializationsDisabled();
}
{code}
Error (looks like the mapping is expected to be bijection but it is not):
{code}
Caused by: java.lang.IllegalArgumentException: target out of range
at org.apache.calcite.util.Permutation.<init>(Permutation.java:69)
at org.apache.calcite.util.mapping.Mappings.bijection(Mappings.java:394)
at
org.apache.calcite.rel.mutable.MutableRels.createProject(MutableRels.java:142)
at
org.apache.calcite.plan.SubstitutionVisitor.unifyAggregates(SubstitutionVisitor.java:1269)
at
org.apache.calcite.plan.SubstitutionVisitor$AggregateOnProjectToAggregateUnifyRule.apply(SubstitutionVisitor.java:1345)
at
org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:531)
at
org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:466)
{code}
h2. Issue 2: result mismatch
{code}
@Test public void testMatResultsMismatch() {
CalciteAssert.that()
.withMaterializations(
HR_FKUK_MODEL,
"m0",
"select avg(\"salary\"), count(*), max(\"salary\"),
sum(\"salary\"), min(\"salary\"), \"empid\" from \"emps\" group by \"empid\"",
"m1",
"select avg(\"salary\"), count(*), max(\"salary\"),
sum(\"salary\"), min(\"salary\"), \"deptno\", \"empid\" from \"emps\" group by
\"empid\", \"deptno\""
)
.query(
"select count(*), \"empid\" from \"emps\" group by \"empid\" order
by count(*) desc limit 50"
)
.enableMaterializations(true)
.explainContains("EnumerableTableScan(table=[[hr, m0]])")
.sameResultWithMaterializationsDisabled();
}
{code}
Error is the same as in the previous case, but if using a workaround to disable
MaterializedViewSubstitutionVisitor, there will be a result mismatch:
{code}
java.lang.AssertionError:
Expected: "EXPR$0=1; empid=100\nEXPR$0=1; empid=150\nEXPR$0=1;
empid=200\nEXPR$0=1; empid=110\n"
but: was "EXPR$0=1; empid=100\nEXPR$0=1; empid=110\nEXPR$0=1;
empid=150\nEXPR$0=1; empid=200\n"
<Click to see difference>
{code}
> Error while applying rule MaterializedViewAggregateRule(Project-Aggregate):
> ArrayIndexOutOfBoundsException
> ----------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-3052
> URL: https://issues.apache.org/jira/browse/CALCITE-3052
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.19.0
> Reporter: Anton Haidai
> Priority: Major
>
> *Materialized views enabled:*
> # {{select avg(grade), count\(*), max(grade), sum(grade), min(grade), team
> from students group by team}}
> # {{select avg(grade), count\(*), max(grade), sum(grade), min(grade), team,
> faculty from students group by faculty, team}},
> *Query:*
> # {{select count\(*), team from students group by team}}
> *Error* (stacktrace is obtained using the current *master* branch:
> "247c7d4f76"):
> {noformat}
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
> at
> com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:60)
> at org.apache.calcite.rex.RexBuilder.makeInputRef(RexBuilder.java:841)
> at
> org.apache.calcite.rel.rules.AbstractMaterializedViewRule$MaterializedViewAggregateRule.rewriteView(AbstractMaterializedViewRule.java:1507)
> at
> org.apache.calcite.rel.rules.AbstractMaterializedViewRule.perform(AbstractMaterializedViewRule.java:522)
> at
> org.apache.calcite.rel.rules.AbstractMaterializedViewRule$MaterializedViewProjectAggregateRule.onMatch(AbstractMaterializedViewRule.java:1776)
> at
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
> ... 71 common frames omitted
> {noformat}
> Reproducible only if both Materialization views listed are enabled: any
> single one of these two could be successfully used with the query without any
> errors. Looks like is is reproducible when AbstractMaterializedViewRule is
> trying to rewrite one materialized view using the another materialized view.
> Currently, I'm trying to reproduce the issue in "MaterializationTest":
> without a success so far, I'll update the ticket if I'll find a working way
> to reproduce the issue in the test will be discovered.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)