[
https://issues.apache.org/jira/browse/CALCITE-4348?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
xzh_dz updated CALCITE-4348:
----------------------------
Description:
The following example should be recognized by materialized views, but failed.
{code:java}
// code placeholder
org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest
@Test void testAggregateComplexExpression() {
String mv = ""
+ "select \"deptno\", \"salary\", count(\"commission\")\n"
+ "from \"emps\"\n"
+ "group by \"deptno\", \"salary\"";
String query = ""
+ "select \"deptno\" + \"salary\", count(\"commission\")\n"
+ "from \"emps\"\n"
+ "group by \"deptno\" + \"salary\"";
sql(mv, query).ok();
}
{code}
{code:java}
Query:
Aggregate(groupSet: {0}, groupSets: [{0}], calls: [COUNT($1)])
Calc(program: (expr#0..4=[{inputs}], expr#5=[+($t1, $t3)], $f0=[$t5],
commission=[$t4]))
Scan(table: [hr, emps])
mv:
Aggregate(groupSet: {0, 1}, groupSets: [{0, 1}], calls: [COUNT($2)])
Calc(program: (expr#0..4=[{inputs}], deptno=[$t1], salary=[$t3],
commission=[$t4]))
Scan(table: [hr, emps]){code}
Exception:
!image-2020-10-21-11-40-08-353.png|width=606,height=223!
was:
The following example should be recognized by materialized views, but failed.
{code:java}
// code placeholder
org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest
@Test void testAggregateComplexExpression() {
String mv = ""
+ "select \"deptno\", \"salary\", count(\"commission\")\n"
+ "from \"emps\"\n"
+ "group by \"deptno\", \"salary\"";
String query = ""
+ "select \"deptno\" + \"salary\", count(\"commission\")\n"
+ "from \"emps\"\n"
+ "group by \"deptno\" + \"salary\"";
sql(mv, query).ok();
}
{code}
{code:java}
Query:
Aggregate(groupSet: {0}, groupSets: [{0}], calls: [COUNT($1)])
Calc(program: (expr#0..4=[{inputs}], expr#5=[+($t1, $t3)], $f0=[$t5],
commission=[$t4]))
Scan(table: [hr, emps])
mv:
Aggregate(groupSet: {0, 1}, groupSets: [{0, 1}], calls: [COUNT($2)])
Calc(program: (expr#0..4=[{inputs}], deptno=[$t1], salary=[$t3],
commission=[$t4]))
Scan(table: [hr, emps]){code}
Exception:
{code:java}
java.lang.AssertionError: Materialized view failed to be matched by optimized
results:java.lang.AssertionError: Materialized view failed to be matched by
optimized results: at
org.apache.calcite.test.AbstractMaterializedViewTest.checkMaterialize(AbstractMaterializedViewTest.java:112)
at
org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:64)
at
org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:226)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at
org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:291)
at
org.apache.calcite.util.ImmutableBeans$BeanImpl.invoke(ImmutableBeans.java:481)
at com.sun.proxy.$Proxy12.ok(Unknown Source) at
org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest.testAggregateComplexExpression(MaterializedViewSubstitutionVisitorTest.java:646)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
at
org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
at
org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:139)
at
org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:131)
at
org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:81)
at
org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at
org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:43)
at
org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:35)
at
org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at
org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:202)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:198)
at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:135)
at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:69)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
at java.util.ArrayList.forEach(ArrayList.java:1257) at
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
at java.util.ArrayList.forEach(ArrayList.java:1257) at
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
at
org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
at
org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
at
org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at
org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at
org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
at
org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
at
org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
at
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
at
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
at
com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
at
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
{code}
> Materialization recognition fails when query has calculation expression
> -----------------------------------------------------------------------
>
> Key: CALCITE-4348
> URL: https://issues.apache.org/jira/browse/CALCITE-4348
> Project: Calcite
> Issue Type: Wish
> Reporter: xzh_dz
> Priority: Major
> Attachments: image-2020-10-21-11-40-08-353.png
>
>
> The following example should be recognized by materialized views, but failed.
> {code:java}
> // code placeholder
> org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest
> @Test void testAggregateComplexExpression() {
> String mv = ""
> + "select \"deptno\", \"salary\", count(\"commission\")\n"
> + "from \"emps\"\n"
> + "group by \"deptno\", \"salary\"";
> String query = ""
> + "select \"deptno\" + \"salary\", count(\"commission\")\n"
> + "from \"emps\"\n"
> + "group by \"deptno\" + \"salary\"";
> sql(mv, query).ok();
> }
> {code}
> {code:java}
> Query:
> Aggregate(groupSet: {0}, groupSets: [{0}], calls: [COUNT($1)])
> Calc(program: (expr#0..4=[{inputs}], expr#5=[+($t1, $t3)], $f0=[$t5],
> commission=[$t4]))
> Scan(table: [hr, emps])
> mv:
> Aggregate(groupSet: {0, 1}, groupSets: [{0, 1}], calls: [COUNT($2)])
> Calc(program: (expr#0..4=[{inputs}], deptno=[$t1], salary=[$t3],
> commission=[$t4]))
> Scan(table: [hr, emps]){code}
> Exception:
> !image-2020-10-21-11-40-08-353.png|width=606,height=223!
>
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)