[jira] [Created] (CALCITE-3251) BinaryExpression evaluate method support Long type.
xzh_dz created CALCITE-3251: --- Summary: BinaryExpression evaluate method support Long type. Key: CALCITE-3251 URL: https://issues.apache.org/jira/browse/CALCITE-3251 Project: Calcite Issue Type: Wish Reporter: xzh_dz -- This message was sent by Atlassian JIRA (v7.6.14#76016)
[jira] [Created] (CALCITE-3279) java.lang.ExceptionInInitializerError
xzh_dz created CALCITE-3279: --- Summary: java.lang.ExceptionInInitializerError Key: CALCITE-3279 URL: https://issues.apache.org/jira/browse/CALCITE-3279 Project: Calcite Issue Type: Bug Reporter: xzh_dz Attachments: image-2019-08-21-23-17-02-049.png When i run the SparkRules main method.And i get the exception as below. !image-2019-08-21-23-17-02-049.png! -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Created] (CALCITE-3288) linq4j: support Set literals
xzh_dz created CALCITE-3288: --- Summary: linq4j: support Set literals Key: CALCITE-3288 URL: https://issues.apache.org/jira/browse/CALCITE-3288 Project: Calcite Issue Type: Improvement Reporter: xzh_dz -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Created] (CALCITE-3289) Disable test pending fix for Wikipedia format change
xzh_dz created CALCITE-3289: --- Summary: Disable test pending fix for Wikipedia format change Key: CALCITE-3289 URL: https://issues.apache.org/jira/browse/CALCITE-3289 Project: Calcite Issue Type: Test Reporter: xzh_dz Attachments: image-2019-08-24-20-35-39-763.png !image-2019-08-24-20-35-39-763.png|width=522,height=112! -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Created] (CALCITE-3290) evaluate in AbstractNode
xzh_dz created CALCITE-3290: --- Summary: evaluate in AbstractNode Key: CALCITE-3290 URL: https://issues.apache.org/jira/browse/CALCITE-3290 Project: Calcite Issue Type: Improvement Reporter: xzh_dz -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Created] (CALCITE-3293) Add strcmp function
xzh_dz created CALCITE-3293: --- Summary: Add strcmp function Key: CALCITE-3293 URL: https://issues.apache.org/jira/browse/CALCITE-3293 Project: Calcite Issue Type: Improvement Reporter: xzh_dz Add strcmp function -- This message was sent by Atlassian Jira (v8.3.2#803003)
[jira] [Created] (CALCITE-3371) revise doc
xzh_dz created CALCITE-3371: --- Summary: revise doc Key: CALCITE-3371 URL: https://issues.apache.org/jira/browse/CALCITE-3371 Project: Calcite Issue Type: Wish Reporter: xzh_dz h1. revise doc {[@link|https://github.com/link] ProjectToCalcRule} creates this from a {[@link|https://github.com/link] LogicalProject} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3380) implement power method in Expressions.
xzh_dz created CALCITE-3380: --- Summary: implement power method in Expressions. Key: CALCITE-3380 URL: https://issues.apache.org/jira/browse/CALCITE-3380 Project: Calcite Issue Type: Wish Reporter: xzh_dz implement power method in Expressions. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3421) Reuse relMetadataQuery.
xzh_dz created CALCITE-3421: --- Summary: Reuse relMetadataQuery. Key: CALCITE-3421 URL: https://issues.apache.org/jira/browse/CALCITE-3421 Project: Calcite Issue Type: Wish Reporter: xzh_dz Reuse relMetadataQuery in TraitPropagationTest,VolcanoPlannerTraitTest,RelMetadataTest,PlannerTest -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3422) reOpen CALCITE-1751 tests in PigRelBuilderStyleTest.
xzh_dz created CALCITE-3422: --- Summary: reOpen CALCITE-1751 tests in PigRelBuilderStyleTest. Key: CALCITE-3422 URL: https://issues.apache.org/jira/browse/CALCITE-3422 Project: Calcite Issue Type: Wish Reporter: xzh_dz reOpen CALCITE-1751 tests in PigRelBuilderStyleTest after disable. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3426) compensate validConstant type in RexLiteral.
xzh_dz created CALCITE-3426: --- Summary: compensate validConstant type in RexLiteral. Key: CALCITE-3426 URL: https://issues.apache.org/jira/browse/CALCITE-3426 Project: Calcite Issue Type: Wish Reporter: xzh_dz compensate validConstant type in RexLiteral. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3432) RexBuilder construct method with the default of RelDataTypeFactory.
xzh_dz created CALCITE-3432: --- Summary: RexBuilder construct method with the default of RelDataTypeFactory. Key: CALCITE-3432 URL: https://issues.apache.org/jira/browse/CALCITE-3432 Project: Calcite Issue Type: Wish Reporter: xzh_dz RexBuilder construct method with the default of RelDataTypeFactory. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3450) Support Intersect and Minus in RelMdTableReferences.
xzh_dz created CALCITE-3450: --- Summary: Support Intersect and Minus in RelMdTableReferences. Key: CALCITE-3450 URL: https://issues.apache.org/jira/browse/CALCITE-3450 Project: Calcite Issue Type: Wish Reporter: xzh_dz Support Intersect and Minus in RelMdTableReferences. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3451) Support TableModify in RelMdNodeTypes.
xzh_dz created CALCITE-3451: --- Summary: Support TableModify in RelMdNodeTypes. Key: CALCITE-3451 URL: https://issues.apache.org/jira/browse/CALCITE-3451 Project: Calcite Issue Type: Wish Reporter: xzh_dz Support TableModify in RelMdNodeTypes. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3454) Exchange RowCount in MaxRowCount,MinRowCount,RowCount
xzh_dz created CALCITE-3454: --- Summary: Exchange RowCount in MaxRowCount,MinRowCount,RowCount Key: CALCITE-3454 URL: https://issues.apache.org/jira/browse/CALCITE-3454 Project: Calcite Issue Type: Wish Reporter: xzh_dz Exchange RowCount in MaxRowCount,MinRowCount,RowCount -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3467) fix PartialMapping mistake and Cosmetic Change
xzh_dz created CALCITE-3467: --- Summary: fix PartialMapping mistake and Cosmetic Change Key: CALCITE-3467 URL: https://issues.apache.org/jira/browse/CALCITE-3467 Project: Calcite Issue Type: Wish Reporter: xzh_dz fix PartialMapping mistake and Cosmetic Change -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3496) Hive dialect support with cube and with rollup
xzh_dz created CALCITE-3496: --- Summary: Hive dialect support with cube and with rollup Key: CALCITE-3496 URL: https://issues.apache.org/jira/browse/CALCITE-3496 Project: Calcite Issue Type: Wish Reporter: xzh_dz Hive dialect support with cube and with rollup -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3566) Support EnumerableIntersect and EnumerableMinus convert to Logical
xzh_dz created CALCITE-3566: --- Summary: Support EnumerableIntersect and EnumerableMinus convert to Logical Key: CALCITE-3566 URL: https://issues.apache.org/jira/browse/CALCITE-3566 Project: Calcite Issue Type: Wish Reporter: xzh_dz In ToLogicalConverter, EnumerableIntersect and EnumerableMinus can not convert to Logical currently, this PR supports this transformation. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3570) Support MutableSnapshot in MutableRel
xzh_dz created CALCITE-3570: --- Summary: Support MutableSnapshot in MutableRel Key: CALCITE-3570 URL: https://issues.apache.org/jira/browse/CALCITE-3570 Project: Calcite Issue Type: Wish Reporter: xzh_dz Support MutableSnapshot in MutableRel.This PR implements mutual conversion between mutablesnapshot and logicalsnapshot. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3572) Lack of Hints information when serialization and deserialization
xzh_dz created CALCITE-3572: --- Summary: Lack of Hints information when serialization and deserialization Key: CALCITE-3572 URL: https://issues.apache.org/jira/browse/CALCITE-3572 Project: Calcite Issue Type: Wish Reporter: xzh_dz when i try to serialization and deserialization hints as below: {code:java} @Test public void testExplainTerms() { String sql = "select /*+ resource(mem='20Mb') */ empno, ename from emp"; final RelNode rel = tester.convertSqlToRel(sql).rel; RelJsonWriter jsonWriter = new RelJsonWriter(); if(rel instanceof Project) { rel.explain(jsonWriter); final String relJson = jsonWriter.asString(); String s = deserializeAndDumpToTextFormat(getSchema(rel), relJson); System.out.println(s); } } {code} {code:java} { "rels": [ { "id": "0", "relOp": "LogicalTableScan", "table": [ "CATALOG", "SALES", "EMP" ], "inputs": [] }, { "id": "1", "relOp": "LogicalProject", "fields": [ "EMPNO", "ENAME" ], "exprs": [ { "input": 0, "name": "$0" }, { "input": 1, "name": "$1" } ] } ] } {code} I find that result lack of the Hints information, maybe we should support Hints serialization and deserialization. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3607) Support LogicalTableModify in RelShuttle
xzh_dz created CALCITE-3607: --- Summary: Support LogicalTableModify in RelShuttle Key: CALCITE-3607 URL: https://issues.apache.org/jira/browse/CALCITE-3607 Project: Calcite Issue Type: Wish Components: core Reporter: xzh_dz RelShuttle don't support LogicalTableModify,this pr try to support LogicalTableModify in RelShuttle。 -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3626) Can't apply materialized view with a simple sort
xzh_dz created CALCITE-3626: --- Summary: Can't apply materialized view with a simple sort Key: CALCITE-3626 URL: https://issues.apache.org/jira/browse/CALCITE-3626 Project: Calcite Issue Type: Wish Environment: {code:java} @Test public void testSort0() { String mv = "select \"deptno\", \"commission\" from \"emps\" order by \"deptno\""; String query = "select \"deptno\" , \"commission\" from \"emps\" order by \"commission\""; checkMaterialize(mv, query, true); } @Test public void testSort1() { String mv = "select \"deptno\", \"commission\" from \"emps\" order by \"deptno\""; String query = "select \"commission\", \"deptno\" from \"emps\" order by \"commission\""; checkMaterialize(mv, query, true); }{code} Reporter: xzh_dz when i run those codes as below, i get some error messages.it seems like materialized view can not be matched correctly. exception: java.lang.AssertionError: java.lang.AssertionError: Expected: a string containing "EnumerableTableScan(table=[[hr, m0]])" but: was "PLAN=EnumerableSort(sort0=[$0], dir0=[ASC])\n EnumerableCalc(expr#0..4=[\{inputs}], commission=[$t4], deptno=[$t1])\n EnumerableTableScan(table=[[hr, emps]])\n\n" at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6) at org.apache.calcite.test.CalciteAssert.lambda$checkResultContains$7(CalciteAssert.java:429) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:544) at org.apache.calcite.test.CalciteAssert$AssertQuery.lambda$returns$1(CalciteAssert.java:1514) at org.apache.calcite.test.CalciteAssert$AssertQuery.withConnection(CalciteAssert.java:1446) at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1512) at org.apache.calcite.test.CalciteAssert$AssertQuery.explainMatches(CalciteAssert.java:1609) at org.apache.calcite.test.MaterializationTest.checkThatMaterialize(MaterializationTest.java:279) at org.apache.calcite.test.MaterializationTest.checkMaterialize(MaterializationTest.java:239) at org.apache.calcite.test.MaterializationTest.checkMaterialize(MaterializationTest.java:215) at org.apache.calcite.test.MaterializationTest.testSort1(MaterializationTest.java:653) 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
[jira] [Created] (CALCITE-3632) Add IntersectToIntersectUnifyRule in SubstitutionVisitor
xzh_dz created CALCITE-3632: --- Summary: Add IntersectToIntersectUnifyRule in SubstitutionVisitor Key: CALCITE-3632 URL: https://issues.apache.org/jira/browse/CALCITE-3632 Project: Calcite Issue Type: Wish Reporter: xzh_dz when i run those code as below, i got some error messages. {code:java} //MaterializationTest @Test public void testJoinToJoin0() { String mv = "" + "select \"deptno\" from\n" + "\"emps\" intersect select \"deptno\" from \"depts\""; String query = "" + "select \"deptno\" from\n" + "\"depts\" intersect select \"deptno\" from \"emps\""; checkMaterialize(mv, query, true); } {code} java.lang.AssertionError: Expected: a string containing "EnumerableTableScan(table=[[hr, m0]])" but: was "PLAN=EnumerableCalc(expr#0..1=[{inputs}], expr#2=[2:BIGINT], expr#3=[=($t1, $t2)], deptno=[$t0], $condition=[$t3])\n EnumerableAggregate(group=[{0}], agg#0=[COUNT()])\n EnumerableUnion(all=[true])\n EnumerableAggregate(group=[{0}], agg#0=[COUNT()])\nEnumerableTableScan(table=[[hr, depts]])\n EnumerableAggregate(group=[{1}], agg#0=[COUNT()])\n EnumerableTableScan(table=[[hr, emps]])\n\n" at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6) at org.apache.calcite.test.CalciteAssert.lambda$checkResultContains$7(CalciteAssert.java:429) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:544) at org.apache.calcite.test.CalciteAssert$AssertQuery.lambda$returns$1(CalciteAssert.java:1514) at org.apache.calcite.test.CalciteAssert$AssertQuery.withConnection(CalciteAssert.java:1446) at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1512) at org.apache.calcite.test.CalciteAssert$AssertQuery.explainMatches(CalciteAssert.java:1609) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3633) Update Cassandra tests upgrade from junit4 to junit5
xzh_dz created CALCITE-3633: --- Summary: Update Cassandra tests upgrade from junit4 to junit5 Key: CALCITE-3633 URL: https://issues.apache.org/jira/browse/CALCITE-3633 Project: Calcite Issue Type: Wish Reporter: xzh_dz -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3634) Support Intersect and Minus on Calcs for materialized view recognition
xzh_dz created CALCITE-3634: --- Summary: Support Intersect and Minus on Calcs for materialized view recognition Key: CALCITE-3634 URL: https://issues.apache.org/jira/browse/CALCITE-3634 Project: Calcite Issue Type: Wish Reporter: xzh_dz IntersectOnCalcsToIntersectUnifyRule and MinusOnCalcsToMinus is not implemented in SubstitutionVisitor, this pr try to implement it. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3636) Implement RelHint for Sort
xzh_dz created CALCITE-3636: --- Summary: Implement RelHint for Sort Key: CALCITE-3636 URL: https://issues.apache.org/jira/browse/CALCITE-3636 Project: Calcite Issue Type: Wish Reporter: xzh_dz -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3644) Calc on the Intersecrt in target is not being matched
xzh_dz created CALCITE-3644: --- Summary: Calc on the Intersecrt in target is not being matched Key: CALCITE-3644 URL: https://issues.apache.org/jira/browse/CALCITE-3644 Project: Calcite Issue Type: Wish Reporter: xzh_dz {code:java} @Test public void testIntersectToCalcOnIntersect() { final String mv = "" + "select \"deptno\",\"name\" from \"emps\"\n" + "intersect all\n" + "select \"deptno\",\"name\" from \"depts\""; String mv1 = "select \"name\", \"deptno\" from (" + mv + ")"; final String query = "" + "select \"name\",\"deptno\" from \"depts\"\n" + "intersect all\n" + "select \"name\",\"deptno\" from \"emps\""; checkMaterialize(mv1, query, true); } {code} error: {code:java} java.lang.AssertionError: Expected: a string containing "EnumerableTableScan(table=[[hr, m0]])" but: was "PLAN=EnumerableIntersect(all=[true])\n EnumerableCalc(expr#0..3=[{inputs}], name=[$t1], deptno=[$t0])\n EnumerableTableScan(table=[[hr, depts]])\n EnumerableCalc(expr#0..4=[{inputs}], name=[$t2], deptno=[$t1])\n EnumerableTableScan(table=[[hr, emps]])\n\n" at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6) at org.apache.calcite.test.CalciteAssert.lambda$checkResultContains$7(CalciteAssert.java:429) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:544) at org.apache.calcite.test.CalciteAssert$AssertQuery.lambda$returns$1(CalciteAssert.java:1514) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3645) Add columnMappings in digest and explainTerms methods.
xzh_dz created CALCITE-3645: --- Summary: Add columnMappings in digest and explainTerms methods. Key: CALCITE-3645 URL: https://issues.apache.org/jira/browse/CALCITE-3645 Project: Calcite Issue Type: Wish Reporter: xzh_dz -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3653) TableModify convert to Logical
xzh_dz created CALCITE-3653: --- Summary: TableModify convert to Logical Key: CALCITE-3653 URL: https://issues.apache.org/jira/browse/CALCITE-3653 Project: Calcite Issue Type: Wish Reporter: xzh_dz -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3718) Support Intersect and Minus in Bindables
xzh_dz created CALCITE-3718: --- Summary: Support Intersect and Minus in Bindables Key: CALCITE-3718 URL: https://issues.apache.org/jira/browse/CALCITE-3718 Project: Calcite Issue Type: Wish Reporter: xzh_dz Intersect and Minus are not supported in Bindables, this pr try support Intersect and Minus in Bindables. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3740) Materialized view can not be matched in IntersectToCalcOnIntersect
xzh_dz created CALCITE-3740: --- Summary: Materialized view can not be matched in IntersectToCalcOnIntersect Key: CALCITE-3740 URL: https://issues.apache.org/jira/browse/CALCITE-3740 Project: Calcite Issue Type: Wish Reporter: xzh_dz when i try to run codes as below: {code:java} final String intersect = "" + "select \"name\",\"deptno\" from \"emps\"\n" + "intersect all\n" + "select \"name\",\"deptno\" from \"depts\""; final String mv = "" + "select \"name\",\"deptno\" from (" + intersect + ")" + "where \"deptno\" > 100"; final String query = "" + "select \"name\",\"deptno\" from \"depts\" where \"deptno\" > 100\n" + "intersect all\n" + "select \"name\",\"deptno\" from \"emps\" where \"deptno\" > 100"; checkMaterialize(mv, query, true); {code} it should be matched.but i got some error messages: {code:java} java.lang.AssertionError: Expected: a string containing "EnumerableTableScan(table=[[hr, m0]])" but: was "PLAN=EnumerableIntersect(all=[true])\n EnumerableCalc(expr#0..3=[{inputs}], expr#4=[100], expr#5=[>($t0, $t4)], name=[$t1], deptno=[$t0], $condition=[$t5])\n EnumerableTableScan(table=[[hr, depts]])\n EnumerableCalc(expr#0..4=[{inputs}], expr#5=[100], expr#6=[>($t1, $t5)], name=[$t2], deptno=[$t1], $condition=[$t6])\n EnumerableTableScan(table=[[hr, emps]])\n\n" at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:6) at org.apache.calcite.test.CalciteAssert.lambda$checkResultContains$7(CalciteAssert.java:433) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:548) at org.apache.calcite.test.CalciteAssert$AssertQuery.lambda$returns$1(CalciteAssert.java:1518) at org.apache.calcite.test.CalciteAssert$AssertQuery.withConnection(CalciteAssert.java:1450) at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1516) at org.apache.calcite.test.CalciteAssert$AssertQuery.explainMatches(CalciteAssert.java:1712) at org.apache.calcite.test.MaterializationTest.checkThatMaterialize(MaterializationTest.java:278) at org.apache.calcite.test.MaterializationTest.checkMaterialize(MaterializationTest.java:238) at org.apache.calcite.test.MaterializationTest.checkMaterialize(MaterializationTest.java:214) at org.apache.calcite.test.MaterializationTest.testIntersectToCalcOnIntersect1(MaterializationTest.java:2921) 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.
[jira] [Created] (CALCITE-3938) implement visit LogicalCalc in RelShuttleImpl
xzh_dz created CALCITE-3938: --- Summary: implement visit LogicalCalc in RelShuttleImpl Key: CALCITE-3938 URL: https://issues.apache.org/jira/browse/CALCITE-3938 Project: Calcite Issue Type: Wish Reporter: xzh_dz visit LogicalCalc in RelShuttleImpl -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3958) revise description of gradle.properties and SubstitutionVisitor
xzh_dz created CALCITE-3958: --- Summary: revise description of gradle.properties and SubstitutionVisitor Key: CALCITE-3958 URL: https://issues.apache.org/jira/browse/CALCITE-3958 Project: Calcite Issue Type: Wish Reporter: xzh_dz 1. revise cassandra and piglet gradle.properties 2. revise doc of SubstitutionVisitor -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3959) Implement INSTR function
xzh_dz created CALCITE-3959: --- Summary: Implement INSTR function Key: CALCITE-3959 URL: https://issues.apache.org/jira/browse/CALCITE-3959 Project: Calcite Issue Type: Wish Reporter: xzh_dz Implement INSTR function -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3960) Oracle and SparkSql dialect allow as
xzh_dz created CALCITE-3960: --- Summary: Oracle and SparkSql dialect allow as Key: CALCITE-3960 URL: https://issues.apache.org/jira/browse/CALCITE-3960 Project: Calcite Issue Type: Wish Reporter: xzh_dz -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3971) Support Calc in RelMdColumnOrigins
xzh_dz created CALCITE-3971: --- Summary: Support Calc in RelMdColumnOrigins Key: CALCITE-3971 URL: https://issues.apache.org/jira/browse/CALCITE-3971 Project: Calcite Issue Type: Wish Reporter: xzh_dz In my project, we often use `RelColumnOrigin` to find metadata information for columns. When i try to get origin column , and i got exception as below, the exception can be reproduced. {code:java} final String sql = "select name,deptno from dept"; final RelNode relNode = convertSql(sql); final HepProgram program = new HepProgramBuilder(). addRuleInstance(ProjectToCalcRule.INSTANCE).build(); final HepPlanner planner = new HepPlanner(program); planner.setRoot(relNode); final RelNode calc = planner.findBestExp(); final RelMetadataQuery mq = calc.getCluster().getMetadataQuery(); final RelColumnOrigin nameColumn = mq.getColumnOrigin(calc, 0); assertThat(nameColumn.getOriginColumnOrdinal(), is(1)); {code} java.lang.NullPointerException at org.apache.calcite.test.RelMetadataTest.testCalcColumnOriginsTable(RelMetadataTest.java:391) 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) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3984) Support exchange operator in RelFieldTrimmer
xzh_dz created CALCITE-3984: --- Summary: Support exchange operator in RelFieldTrimmer Key: CALCITE-3984 URL: https://issues.apache.org/jira/browse/CALCITE-3984 Project: Calcite Issue Type: Wish Reporter: xzh_dz RelFieldTrimmer does not support trim unused fields in exchange operator now. Such as below: {code:java} final RelBuilder builder = RelBuilder.create(config().build()); final RelNode root = builder.scan("EMP") .project(builder.field("EMPNO"), builder.field("ENAME"), builder.field("DEPTNO")) .exchange(RelDistributions.hash(Lists.newArrayList(1))) .project(builder.field("EMPNO"), builder.field("ENAME")) .build(); {code} RelNode root: {code:java} LogicalProject(EMPNO=[$0], ENAME=[$1]) LogicalExchange(distribution=[hash[1]]) LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7]) LogicalTableScan(table=[[scott, EMP]]) {code} The right result should be: {code:java} LogicalExchange(distribution=[hash[1]]) LogicalProject(EMPNO=[$0], ENAME=[$1]) LogicalTableScan(table=[[scott, EMP]]) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3988) Intersect in RelMdRowCount doesn't take into account 'intersect all'
xzh_dz created CALCITE-3988: --- Summary: Intersect in RelMdRowCount doesn't take into account 'intersect all' Key: CALCITE-3988 URL: https://issues.apache.org/jira/browse/CALCITE-3988 Project: Calcite Issue Type: Wish Reporter: xzh_dz Same as [https://issues.apache.org/jira/browse/CALCITE-3287|https://issues.apache.org/jira/browse/CALCITE-3287]. Intersect in RelMdRowCount.java doesn't take into account 'intersect all' . {code:java} public Double getRowCount(Intersect rel, RelMetadataQuery mq) { Double rowCount = null; for (RelNode input : rel.getInputs()) { Double partialRowCount = mq.getRowCount(input); if (rowCount == null || partialRowCount != null && partialRowCount < rowCount) { rowCount = partialRowCount; } } return rowCount; } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4005) Support calc operator in RelMdAllPredicates and RelMdExpressionLineage
xzh_dz created CALCITE-4005: --- Summary: Support calc operator in RelMdAllPredicates and RelMdExpressionLineage Key: CALCITE-4005 URL: https://issues.apache.org/jira/browse/CALCITE-4005 Project: Calcite Issue Type: Wish Reporter: xzh_dz Support calc operator in RelMdAllPredicates and RelMdExpressionLineage. and also support setOp and sortExchange operator. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4020) Support Calc operator in RelFieldTrimmer
xzh_dz created CALCITE-4020: --- Summary: Support Calc operator in RelFieldTrimmer Key: CALCITE-4020 URL: https://issues.apache.org/jira/browse/CALCITE-4020 Project: Calcite Issue Type: Wish Reporter: xzh_dz Support Calc operator in RelFieldTrimmer -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4022) After SqlInsert is traversed by SqlShuttle, SqlBasicCall throws UnsupportedOperationException
xzh_dz created CALCITE-4022: --- Summary: After SqlInsert is traversed by SqlShuttle, SqlBasicCall throws UnsupportedOperationException Key: CALCITE-4022 URL: https://issues.apache.org/jira/browse/CALCITE-4022 Project: Calcite Issue Type: Wish Reporter: xzh_dz Attachments: image-2020-05-25-17-38-36-009.png {code:java} SqlNode a = sqlNode.accept(new SqlShuttle() { @Override public SqlNode visit(SqlIdentifier identifier) { return new SqlIdentifier(identifier.names, identifier.getParserPosition()); } }); {code} !image-2020-05-25-17-38-36-009.png! -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4040) Nonstandard SqlAggFunction rollup NPE Exception
xzh_dz created CALCITE-4040: --- Summary: Nonstandard SqlAggFunction rollup NPE Exception Key: CALCITE-4040 URL: https://issues.apache.org/jira/browse/CALCITE-4040 Project: Calcite Issue Type: Wish Reporter: xzh_dz When i try to rollup some SqlAggFunctions in my project,I find something wrong. A case can be reproduced as below: MaterializationTest: {code:java} @Test public void testSqlAggFunctionRollup() { checkNoMaterialize( "select \"empid\", stddev_pop(\"deptno\") from \"emps\" group by \"empid\", \"deptno\"", "select \"empid\", stddev_pop(\"deptno\") from \"emps\" group by \"empid\"", HR_FKUK_MODEL); } {code} If sql is not materialized, it should not throw an exception. Exception: {code:java} java.sql.SQLException: Error while executing SQL "explain plan for select "empid", stddev_pop("deptno") from "emps" group by "empid"": null at org.apache.calcite.avatica.Helper.createException(Helper.java:56) at org.apache.calcite.avatica.Helper.createException(Helper.java:41) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:528) Caused by: java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:203) at org.apache.calcite.rel.core.AggregateCall.(AggregateCall.java:98) at org.apache.calcite.rel.core.AggregateCall.create(AggregateCall.java:198) at org.apache.calcite.plan.SubstitutionVisitor.unifyAggregates(SubstitutionVisitor.java:1854) at org.apache.calcite.plan.SubstitutionVisitor$AggregateToAggregateUnifyRule.apply(SubstitutionVisitor.java:1545) at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:544) at org.apache.calcite.plan.SubstitutionVisitor.go(SubstitutionVisitor.java:478) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4062) When deserialize UDF array type from json string, throw an exception
xzh_dz created CALCITE-4062: --- Summary: When deserialize UDF array type from json string, throw an exception Key: CALCITE-4062 URL: https://issues.apache.org/jira/browse/CALCITE-4062 Project: Calcite Issue Type: Wish Reporter: xzh_dz Function serialization and deserialization are often involved. When I run some tests, I find that some functions have exceptions during deserialization. The exception can be reproduced as below: RelWriterTest: {code:java} @Test void test() { final FrameworkConfig config = RelBuilderTest.config().build(); final RelBuilder builder = RelBuilder.create(config); final RelNode rel = builder .scan("EMP") .project( builder.call(new MockSqlOperatorTable.SplitFunction(), builder.field("ENAME"), builder.literal(","))) .build(); String relJson = RelOptUtil.dumpPlan("", rel, SqlExplainFormat.JSON, SqlExplainLevel.EXPPLAN_ATTRIBUTES); String s = deserializeAndDumpToTextFormat(getSchema(rel), relJson); System.out.println(s); } MockSqlOperatorTable: public static class SplitFunction extends SqlFunction { public SplitFunction() { super("split", new SqlIdentifier("split", SqlParserPos.ZERO), SqlKind.OTHER_FUNCTION, null, null, OperandTypes.family(SqlTypeFamily.STRING, SqlTypeFamily.STRING), null, SqlFunctionCategory.USER_DEFINED_FUNCTION); } @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) { final RelDataTypeFactory typeFactory = opBinding.getTypeFactory(); return typeFactory.createArrayType(typeFactory.createSqlType(SqlTypeName.VARCHAR), -1); } } {code} Exception: {code:java} java.lang.RuntimeException: java.lang.RuntimeException: java.lang.AssertionError: use createArrayType() instead at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:182) at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:126) at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:144) at org.apache.calcite.plan.RelWriterTest.deserializeAndDumpToTextFormat(RelWriterTest.java:838) at org.apache.calcite.plan.RelWriterTest.testArrayType(RelWriterTest.java:811) 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(
[jira] [Created] (CALCITE-4194) Materialized recognition failed when query contains cast type conversion
xzh_dz created CALCITE-4194: --- Summary: Materialized recognition failed when query contains cast type conversion Key: CALCITE-4194 URL: https://issues.apache.org/jira/browse/CALCITE-4194 Project: Calcite Issue Type: Wish Reporter: xzh_dz There is a semantic equivalent case, which should be able to materialize and identify successfully, but failed. This case can be reproduced as below. {code:java} // MaterializedViewSubstitutionVisitorTest @Test void testCastMvMatch() { sql( "select \"empid\", count(\"deptno\") from \"emps\" where \"empid\" > 10 group by \"empid\"", "select \"empid\", count(cast(\"deptno\" as bigint)) from \"emps\" where \"empid\" > 10 group by \"empid\"") .ok(); } {code} Here is the error message: {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:227) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:275) at org.apache.calcite.util.ImmutableBeans$BeanImpl.invoke(ImmutableBeans.java:446) at com.sun.proxy.$Proxy12.ok(Unknown Source) at org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest.testCastMvMatch(MaterializedViewSubstitutionVisitorTest.java:124) 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(No
[jira] [Created] (CALCITE-4198) Query contains AVG function, materialized view contains SUM and COUNT functions, and materialized recognition fails
xzh_dz created CALCITE-4198: --- Summary: Query contains AVG function, materialized view contains SUM and COUNT functions, and materialized recognition fails Key: CALCITE-4198 URL: https://issues.apache.org/jira/browse/CALCITE-4198 Project: Calcite Issue Type: Wish Reporter: xzh_dz There is a semantic equivalent case, which should be able to materialize and identify successfully, materialized view can express the calculation logic of query,but failed. This case can be reproduced as below. {code:java} // MaterializedViewSubstitutionVisitorTest @Test void testAvgMvMatch() { sql( "select \"empid\", sum(\"salary\"), count(\"salary\") from \"emps\" where \"empid\" > 10 group by \"empid\"", "select \"empid\", avg(\"salary\") from \"emps\" where \"empid\" > 10 group by \"empid\"") .ok(); } {code} The error message: {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:227) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:275) at org.apache.calcite.util.ImmutableBeans$BeanImpl.invoke(ImmutableBeans.java:446) at com.sun.proxy.$Proxy12.ok(Unknown Source) at org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest.testAvgMvMatch(MaterializedViewSubstitutionVisitorTest.java:101) 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) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4250) Failed to get original column of aggregate operator
xzh_dz created CALCITE-4250: --- Summary: Failed to get original column of aggregate operator Key: CALCITE-4250 URL: https://issues.apache.org/jira/browse/CALCITE-4250 Project: Calcite Issue Type: Wish Reporter: xzh_dz We often use `RelMetadataQuery` to track column lineage, but failed to get original column of aggregate operator. This case can be reproduced as below: {code:java} // @Test void testAggregateRelMdColumnOrigins() { final RelBuilder relBuilder = RelBuilder.create(config().build()); final LogicalProject project = (LogicalProject) relBuilder.scan("EMP") .project(relBuilder.field("EMPNO"), relBuilder.field("ENAME"), relBuilder.field("JOB"), relBuilder.field("SAL"), relBuilder.field("DEPTNO")).build(); final LogicalAggregate aggregate = (LogicalAggregate) relBuilder.push(project) .aggregate( relBuilder.groupKey(relBuilder.field(1, 0, "DEPTNO")), relBuilder.count(relBuilder.field(1, 0, "SAL"))) .build(); RelMetadataQuery mq = aggregate.getCluster().getMetadataQuery(); final RelColumnOrigin nameColumn = mq.getColumnOrigin(aggregate , 0); assertThat(nameColumn.getOriginTable().getRowType().getFieldNames().get(7).equals("DEPTNO"), is(true)); System.out.println(nameColumn.getOriginColumnOrdinal()); // 5 } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4251) Overload RelMetadataQuery#getColumnOrigin method
xzh_dz created CALCITE-4251: --- Summary: Overload RelMetadataQuery#getColumnOrigin method Key: CALCITE-4251 URL: https://issues.apache.org/jira/browse/CALCITE-4251 Project: Calcite Issue Type: Wish Reporter: xzh_dz A case: {code:java} // select col1, col2 , sum(count_col4) as sum_col4 from ( select col1, col2, col3, count(col4) as count_col4 from tbl group by col1, col2, col3 ) group by col1, col2 {code} When i try to get the `sum_col4` origin column field,it will return null and it is derived. we always get the origin column although it is derived. We should overload this method. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4296) Materialization recognition fail, cannot match Calc on top of materialized view
xzh_dz created CALCITE-4296: --- Summary: Materialization recognition fail, cannot match Calc on top of materialized view Key: CALCITE-4296 URL: https://issues.apache.org/jira/browse/CALCITE-4296 Project: Calcite Issue Type: Wish Reporter: xzh_dz MaterializedViewSubstitutionVisitorTest {code:java} // code placeholder @Test void test() { String mv = "" + "select sum(\"salary\"), \"deptno\"\n" + "from \"emps\"\n" + "group by \"deptno\""; String query = "" + "select \"deptno\"\n" + "from \"emps\"\n" + "group by \"deptno\""; sql(mv, query).ok(); } {code} exception: {code:java} // code placeholder 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) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4348) Materialization recognition fails when query has calculation expression
xzh_dz created CALCITE-4348: --- Summary: 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 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.ju
[jira] [Created] (CALCITE-4373) Count(distinct Col) materialized view recognition failed
xzh_dz created CALCITE-4373: --- Summary: Count(distinct Col) materialized view recognition failed Key: CALCITE-4373 URL: https://issues.apache.org/jira/browse/CALCITE-4373 Project: Calcite Issue Type: Wish Reporter: xzh_dz Attachments: image-2020-11-03-10-56-57-804.png {code:java} org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest // code placeholder @Test void testCountDistinctInAgg() { final String mv = "" + "select \"name\", \"commission\", \"deptno\"\n" + "from \"emps\" group by \"name\", \"commission\", \"deptno\""; final String query = "" + "select \"name\", \"commission\", count(distinct \"deptno\") as cnt\n" + "from \"emps\" group by \"name\", \"commission\""; sql(mv, query).withChecker( resultContains("" + "LogicalCalc(expr#0..1=[{inputs}], expr#2=['hello':VARCHAR], expr#3=[CAST($t0)" + ":VARCHAR], expr#4=[=($t2, $t3)], CNT=[$t1], $condition=[$t4])\n" + " EnumerableTableScan(table=[[hr, MV0]])")).ok(); } {code} Error: !image-2020-11-03-10-56-57-804.png|width=511,height=99! -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4384) Predicate can not satisfy the condition of materialized recognition
xzh_dz created CALCITE-4384: --- Summary: Predicate can not satisfy the condition of materialized recognition Key: CALCITE-4384 URL: https://issues.apache.org/jira/browse/CALCITE-4384 Project: Calcite Issue Type: Wish Reporter: xzh_dz In the following example, materialized views cannot contain predicate conditions contained in queries and should not be materialized, but they are materialized. {code:java} org.apache.calcite.test.MaterializedViewRelOptRulesTest#testJoinMaterialization10 // code placeholder @Test void testJoinMaterialization10() { sql("select \"depts\".\"deptno\", \"dependents\".\"empid\"\n" + "from \"depts\"\n" + "join \"dependents\" on (\"depts\".\"name\" = \"dependents\".\"name\")\n" + "join \"emps\" on (\"emps\".\"deptno\" = \"depts\".\"deptno\")\n" + "where \"depts\".\"deptno\" > 30", "select \"dependents\".\"empid\"\n" + "from \"depts\"\n" + "join \"dependents\" on (\"depts\".\"name\" = \"dependents\".\"name\")\n" + "join \"emps\" on (\"emps\".\"deptno\" = \"depts\".\"deptno\")\n" + "where \"depts\".\"deptno\" > 10") .withChecker( resultContains("EnumerableUnion(all=[true])", "EnumerableTableScan(table=[[hr, MV0]])", "expr#5=[Sarg[(10..30]]], expr#6=[SEARCH($t0, $t5)]")) .ok(); } {code} If we exchange their predicate conditions, they should be identified by materialization. {code:java} // code placeholder org.apache.calcite.test.MaterializedViewRelOptRulesTest#testJoinMaterialization10 @Test void testJoinMaterialization10() { sql("select \"depts\".\"deptno\", \"dependents\".\"empid\"\n" + "from \"depts\"\n" + "join \"dependents\" on (\"depts\".\"name\" = \"dependents\".\"name\")\n" + "join \"emps\" on (\"emps\".\"deptno\" = \"depts\".\"deptno\")\n" + "where \"depts\".\"deptno\" > 10", "select \"dependents\".\"empid\"\n" + "from \"depts\"\n" + "join \"dependents\" on (\"depts\".\"name\" = \"dependents\".\"name\")\n" + "join \"emps\" on (\"emps\".\"deptno\" = \"depts\".\"deptno\")\n" + "where \"depts\".\"deptno\" > 30") .withChecker( resultContains("EnumerableCalc(expr#0..1=[{inputs}], expr#2=[30], expr#3=[<($t2, $t0)" + "], empid=[$t1], $condition=[$t3])\n" + " EnumerableTableScan(table=[[hr, MV0]])")) .ok(); } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4386) Support RelShuttle visit specific logical operators
xzh_dz created CALCITE-4386: --- Summary: Support RelShuttle visit specific logical operators Key: CALCITE-4386 URL: https://issues.apache.org/jira/browse/CALCITE-4386 Project: Calcite Issue Type: Wish Reporter: xzh_dz In the current implementation, some operators, such as `LogicalProject` and `LogicalFilter`, can be directly accessed by `Relshuttle`, while others, such as `LogicalCalc` and `LogicalWindow`, cannot be accessed directly. `RelShuttle` is a very important tool class. Usually, we will do equivalent transformation of relational algebra in the process of relational algebra optimization. This PR will cover the method of the operator visit `RelShuttle`, and the specific operator can be accessed directly by visiting `RelNode`. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4391) When the join condition order is different, materialized view recognition fails
xzh_dz created CALCITE-4391: --- Summary: When the join condition order is different, materialized view recognition fails Key: CALCITE-4391 URL: https://issues.apache.org/jira/browse/CALCITE-4391 Project: Calcite Issue Type: Wish Reporter: xzh_dz When the child nodes of join are identical, but the order of join conditions is different, materialized view recognition will fail. {code:java} // code placeholder String query = "" + "select a.empid, a.deptno\n" + "from emps a left join emps_table b\n" + "on a.empid = b.empid and a.deptno = b.deptno"; String mvLogic = "" + "select a.deptno, a.empid\n" + "from emps a left join emps_table b\n" + "on a.deptno = b.deptno and a.empid = b.empid"; Query: LogicalProject(empid=[$0], deptno=[$1]) LogicalJoin(condition=[AND(=($0, $5), =($1, $6))], joinType=[left]) LogicalTableScan(table=[[default, emps]]) LogicalTableScan(table=[[default, emps_table]]) MV: LogicalProject(deptno=[$1], empid=[$0]) LogicalJoin(condition=[AND(=($1, $6), =($0, $5))], joinType=[left]) LogicalTableScan(table=[[default, emps]]) LogicalTableScan(table=[[default, emps_table]]){code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4395) Add an interface in RelOptMaterializations to allow registering normalization rules
xzh_dz created CALCITE-4395: --- Summary: Add an interface in RelOptMaterializations to allow registering normalization rules Key: CALCITE-4395 URL: https://issues.apache.org/jira/browse/CALCITE-4395 Project: Calcite Issue Type: Wish Reporter: xzh_dz In the current framework of materialized recognition, the commonly used relational algebra materialized view recognition algorithm has been implemented, but in specific scenarios, users need to customize the algorithm of materialized view recognition to enhance the ability of materialized view recognition. The algorithm of user-defined materialized view recognition has been implemented here[1]. In addition, the ability of normalization is a very important point before materialized recognition. Normalization can simplify the difficulty of materialized view recognition. Currently, the ability of normalization based on relation algebra can not well support the needs of users. Users need to be able to customize normalization rules, which may be equivalent transformation of some relational algebra. Therefore, we should allow users to customize some normalization algorithms, enhance the normalization ability before the recognition of materialized views. [1][Add an interface in RelOptMaterializations to allow registering UnifyRule|https://github.com/apache/calcite/pull/2094] -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4400) A tool method explain Calc operator
xzh_dz created CALCITE-4400: --- Summary: A tool method explain Calc operator Key: CALCITE-4400 URL: https://issues.apache.org/jira/browse/CALCITE-4400 Project: Calcite Issue Type: Wish Reporter: xzh_dz `Calc` is an operator combining `Project` and `Filter`. In a project development, `Calc` operator is usually used to simplify the operator of `Project` and `Filter`, and facilitate the optimization of relational algebra. Usually, `Calc` operator is needed to process `Project` and `Filter` information.Explain Calc operator is often needed in materialized view recognition.A tool is needed to explain Calc to get `Project` (RexNodes) and `Filter` (RexNode). In relation algebra optimization, it will be very convenient to process `Calc` operator. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4407) Support unparse special syntax when operator is DELETA
xzh_dz created CALCITE-4407: --- Summary: Support unparse special syntax when operator is DELETA Key: CALCITE-4407 URL: https://issues.apache.org/jira/browse/CALCITE-4407 Project: Calcite Issue Type: Wish Reporter: xzh_dz Attachments: image-2020-11-18-16-12-18-340.png This exception can be reproduced as below: SqlParserTest: {code:java} // code placeholder @Test void testSqlDeleteSqlBasicCallToString() throws Exception { final String sql0 = "delete from emps"; final SqlNode sqlNode0 = getSqlParser(sql0).parseStmt(); final SqlNode sqlNodeVisited0 = sqlNode0.accept(new SqlShuttle() { @Override public SqlNode visit(SqlIdentifier identifier) { return new SqlIdentifier(identifier.names, identifier.getParserPosition()); } }); System.out.println(sqlNodeVisited0.toString()); }{code} Exception: {code:java} // code placeholder java.lang.UnsupportedOperationException: class org.apache.calcite.sql.SqlSyntax$7: SPECIALjava.lang.UnsupportedOperationException: class org.apache.calcite.sql.SqlSyntax$7: SPECIAL at org.apache.calcite.util.Util.needToImplement(Util.java:1080) at org.apache.calcite.sql.SqlSyntax$7.unparse(SqlSyntax.java:128) at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:377) at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:453) at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:103) at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:155) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-3013) support CeilFuncBigInt TO
xzh_dz created CALCITE-3013: --- Summary: support CeilFuncBigInt TO Key: CALCITE-3013 URL: https://issues.apache.org/jira/browse/CALCITE-3013 Project: Calcite Issue Type: Test Reporter: xzh_dz -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (CALCITE-4534) When TableScan has different order, materialized view recognition fails.
xzh_dz created CALCITE-4534: --- Summary: When TableScan has different order, materialized view recognition fails. Key: CALCITE-4534 URL: https://issues.apache.org/jira/browse/CALCITE-4534 Project: Calcite Issue Type: Wish Reporter: xzh_dz In the project, when TableScan has different order in the Join operator, materialized view recognition fails. {code:java} // code placeholder org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest#testJoinMaterialization @Test void testJoinMaterialization() { String q = "select \"empid\" from \"emps\"\n" + "join \"depts\" using (\"deptno\")"; String m = "select \"empid\" from \"depts\"\n" + "join \"emps\" using (\"deptno\")"; sql(m, q).ok(); } {code} {code:java} // code placeholder 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:114) at org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:66) at org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:228) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:299) at org.apache.calcite.util.ImmutableBeans$BeanImpl.invoke(ImmutableBeans.java:480) at com.sun.proxy.$Proxy13.ok(Unknown Source) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4566) When query contains multiple `AggregateCall`s, materialized view recognition fails
xzh_dz created CALCITE-4566: --- Summary: When query contains multiple `AggregateCall`s, materialized view recognition fails Key: CALCITE-4566 URL: https://issues.apache.org/jira/browse/CALCITE-4566 Project: Calcite Issue Type: Wish Reporter: xzh_dz {code:java} // code placeholder org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest @Test void testMutilAggCallsMvMatch() { final String mv0 = "" + "select \"name\", sum(\"deptno\") as sum_deptno\n" + "from \"emps\" group by \"name\""; final String mv1 = "" + "select \"name\", count(distinct \"deptno\")\n" + "from \"emps\" group by \"name\""; final String query = "" + "select count(distinct \"deptno\"), sum(\"deptno\") as sum_deptno\n" + "from \"emps\" group by \"name\""; sql(query, mv0, mv1).withChecker( resultContains("")).ok(); } protected Sql sql(String query, String materialize0, String materialize1) { return ImmutableBeans.create(Sql.class) .withMaterializations(ImmutableList.of(Pair.of(materialize0, "MV0"), Pair.of(materialize1, "MV1"))) .withQuery(query) .withTester(this); } {code} Exception: {code:java} // code placeholder java.lang.AssertionError: Materialized view failed to be matched by optmized results:java.lang.AssertionError: Materialized view failed to be matched by optmized results: at org.apache.calcite.test.AbstractMaterializedViewTest.checkMaterialize(AbstractMaterializedViewTest.java:120) at org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:65) at org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:236) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:275) at org.apache.calcite.util.ImmutableBeans$BeanImpl.invoke(ImmutableBeans.java:446) at com.sun.proxy.$Proxy12.ok(Unknown Source) at org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest.testMutilAggCallsMvMatch(MaterializedViewSubstitutionVisitorTest.java:1024) 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.aroun
[jira] [Created] (CALCITE-4624) When query contains complex function, materialized view recognition fails
xzh_dz created CALCITE-4624: --- Summary: When query contains complex function, materialized view recognition fails Key: CALCITE-4624 URL: https://issues.apache.org/jira/browse/CALCITE-4624 Project: Calcite Issue Type: Wish Reporter: xzh_dz {code:java} // code placeholder org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest#testComplexOverWindowFunction @Test void testComplexOverWindowFunction() { final String mv = "" + "select \"deptno\", cos(\"empid\"), row_number() OVER (PARTITION BY \"empid\")\n" + "from \"emps\""; final String query = "" + "select cos(\"empid\"), row_number() OVER (PARTITION BY \"empid\"), \"deptno\"\n" + "from \"emps\""; sql(mv, query).ok(); } {code} Exception: {code:java} // code placeholder Materialized view failed to be matched by optimized results: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:116) at org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:67) at org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:229) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:299) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4770) Design of SearchMvService
xzh_dz created CALCITE-4770: --- Summary: Design of SearchMvService Key: CALCITE-4770 URL: https://issues.apache.org/jira/browse/CALCITE-4770 Project: Calcite Issue Type: New Feature Reporter: xzh_dz In the data system, materialized view can speed up SQL query. Materialized view represents the pre-calculated SQL logic of the target table and contains real data. In the project, we use materialized views to speed up SQL queries, use the materialized view recognition technology to identify materialized views, and enhance the ability of materialized recognition. However, with more and more materialized views , materialized view recognition takes a lot of time, which seriously affects the performance of SQL queries. With this problem, we propose a design of accurate search materialized view based on operator features. DOC:[Design of SearchMvService|[https://docs.google.com/document/d/1mmAsK_uW-fBs893JERP1gspMurX2lNXcVGeesP4XUqQ/edit]] Welcome to discuss and expect more feedback,thank you. -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4774) When predicate conditions are equivalent, materialized view recognition fails.
xzh_dz created CALCITE-4774: --- Summary: When predicate conditions are equivalent, materialized view recognition fails. Key: CALCITE-4774 URL: https://issues.apache.org/jira/browse/CALCITE-4774 Project: Calcite Issue Type: New Feature Reporter: xzh_dz {code:java} // code placeholder org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest @Test void testRexCondition() { final String mv = "" + "select \"name\"\n" + "from \"emps\"\n" + "where \"deptno\" > 100 and \"deptno\" > 50\n" + "group by \"name\""; final String query = "" + "select \"name\"\n" + "from \"emps\"\n" + "where \"deptno\" > 100" + "group by \"name\""; sql(mv, query).withChecker( resultContains("" + "EnumerableTableScan(table=[[hr, MV0]])")).ok(); } {code} Materialized view failed to be matched by optimized results: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:116) at org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:67) at org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:229) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4778) Exchange operator deserialize fail
xzh_dz created CALCITE-4778: --- Summary: Exchange operator deserialize fail Key: CALCITE-4778 URL: https://issues.apache.org/jira/browse/CALCITE-4778 Project: Calcite Issue Type: Improvement Reporter: xzh_dz {code:java} // code placeholder org.apache.calcite.plan.RelWriterTest @Test public void testExchange() { final FrameworkConfig config = RelBuilderTest.config().build(); final RelBuilder builder = RelBuilder.create(config); final RelNode rel = builder .scan("EMP") .exchange(RelDistributions.hash(ImmutableList.of(0, 1))) .build(); final String relJson = RelOptUtil.dumpPlan("", rel, SqlExplainFormat.JSON, SqlExplainLevel.EXPPLAN_ATTRIBUTES); String s = deserializeAndDumpToTextFormat(getSchema(rel), relJson); final String expected = "" + "LogicalExchange(distribution=[hash[0, 1]])\n" + " LogicalTableScan(table=[[scott, EMP]])\n"; assertThat(s, isLinux(expected)); } {code} java.lang.NullPointerException: no entry for tag collationjava.lang.NullPointerException: no entry for tag collationjava.lang.RuntimeException: java.lang.NullPointerException: no entry for tag collation at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:193) at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:135) at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:153) Caused by: java.lang.NullPointerException: no entry for tag collationCaused by: java.lang.NullPointerException: no entry for tag collation at java.util.Objects.requireNonNull(Objects.java:290) at org.apache.calcite.rel.externalize.RelJsonReader$2.getNonNull(RelJsonReader.java:202) at org.apache.calcite.rel.externalize.RelJsonReader$2.getCollation(RelJsonReader.java:260) at org.apache.calcite.rel.core.Exchange.(Exchange.java:73) at org.apache.calcite.rel.logical.LogicalExchange.(LogicalExchange.java:44) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.apache.calcite.rel.externalize.RelJsonReader.readRel(RelJsonReader.java:289) at org.apache.calcite.rel.externalize.RelJsonReader.readRels(RelJsonReader.java:107) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4779) GroupSet contains constant, materialized view recognition failed
xzh_dz created CALCITE-4779: --- Summary: GroupSet contains constant, materialized view recognition failed Key: CALCITE-4779 URL: https://issues.apache.org/jira/browse/CALCITE-4779 Project: Calcite Issue Type: Improvement Reporter: xzh_dz {code:java} // code placeholder org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest @Test void testCountDistinct() { final String mv = "" + "select \"deptno\", \"empid\"\n" + "from \"emps\"\n" + "group by \"deptno\", \"empid\""; final String query = "" + "select 1, \"deptno\"\n" + "from \"emps\"\n" + "group by 1, \"deptno\""; sql(mv, query).ok(); } {code} Materialized view failed to be matched by optimized results: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:116) at org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:67) at org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:229) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4780) Unable to derive implicit predicate conditions, materialized view recognition failed
xzh_dz created CALCITE-4780: --- Summary: Unable to derive implicit predicate conditions, materialized view recognition failed Key: CALCITE-4780 URL: https://issues.apache.org/jira/browse/CALCITE-4780 Project: Calcite Issue Type: Improvement Reporter: xzh_dz {code:java} // code placeholder org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest @Test void testPredicate() { final String mv = "" + "select \"deptno\", \"empid\"\n" + "from \"emps\"\n" + "where \"deptno\" >= 1 and \"deptno\" <= 100"; final String query = "" + "select \"deptno\"\n" + "from \"emps\"\n" + "where \"deptno\" + 0 >= 1 and \"deptno\" + 0 <= 100"; sql(mv, query).ok(); } {code} Materialized view failed to be matched by optimized results: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:116) at org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:67) at org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:229) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4783) Dropped the predicate condition after RelFieldTrimmer trim the RelNode
xzh_dz created CALCITE-4783: --- Summary: Dropped the predicate condition after RelFieldTrimmer trim the RelNode Key: CALCITE-4783 URL: https://issues.apache.org/jira/browse/CALCITE-4783 Project: Calcite Issue Type: Improvement Reporter: xzh_dz {code:java} // code placeholder org.apache.calcite.test.SqlToRelConverterTest @Test void testTrim() { final String sql = "select count(*) from emp where ename = '1'"; final RelNode rel = tester.convertSqlToRel(sql).rel; final HepProgramBuilder programBuilder = HepProgram.builder(); programBuilder.addRuleInstance(CoreRules.FILTER_TO_CALC); final HepPlanner planner = new HepPlanner(programBuilder.build()); planner.setRoot(rel); final RelNode calc = planner.findBestExp(); final List relOptTables = RelOptUtil.findAllTables(calc); RelOptSchema relOptSchema = null; if (relOptTables.size() != 0) { relOptSchema = relOptTables.get(0).getRelOptSchema(); } final RelBuilder relBuilder = RelFactories.LOGICAL_BUILDER.create( calc.getCluster(), relOptSchema); final RelFieldTrimmer fieldTrimmer = new RelFieldTrimmer(null, relBuilder); final RelNode trimmed = fieldTrimmer.trim(calc); System.out.println(RelOptUtil.toString(trimmed)); } result: LogicalAggregate(group=[{}], EXPR$0=[COUNT()]) LogicalTableScan(table=[[CATALOG, SALES, EMP]]){code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4794) Arithmetic remainder operator should be simplified
xzh_dz created CALCITE-4794: --- Summary: Arithmetic remainder operator should be simplified Key: CALCITE-4794 URL: https://issues.apache.org/jira/browse/CALCITE-4794 Project: Calcite Issue Type: Improvement Reporter: xzh_dz When I simplify `MOD` operator in my project , an exception is thrown. Exceptions can be reproduced as below. {code:java} // code placeholder @Test void testSimplifyMod() { RexNode caseNode = case_( gt(mod(vIntNotNull(), literal(1)), literal(1)), falseLiteral, trueLiteral); checkSimplify(caseNode, ""); } protected RexNode mod(RexNode n1, RexNode n2) { return rexBuilder.makeCall(SqlStdOperatorTable.MOD, n1, n2); } {code} {code:java} // code placeholder Exception : [0;31;1mFAILURE[0m 0.3sec, org.apache.calcite.rex.[0;1mRexProgramTest[0m > [0;1mtestSimplifyMod()[0m java.lang.IllegalArgumentException: unbound: MOD(?0.notNullInt0, 1) at org.apache.calcite.rex.RexInterpreter.unbound(RexInterpreter.java:92) at org.apache.calcite.rex.RexInterpreter.visitCall(RexInterpreter.java:227) at org.apache.calcite.rex.RexInterpreter.visitCall(RexInterpreter.java:58) at org.apache.calcite.rex.RexCall.accept(RexCall.java:189) at org.apache.calcite.rex.RexVisitor.visitList(RexVisitor.java:63) at org.apache.calcite.rex.RexVisitor.visitList(RexVisitor.java:71) at org.apache.calcite.rex.RexInterpreter.visitCall(RexInterpreter.java:148) at org.apache.calcite.rex.RexInterpreter.visitCall(RexInterpreter.java:58) at org.apache.calcite.rex.RexCall.accept(RexCall.java:189) at org.apache.calcite.rex.RexVisitor.visitList(RexVisitor.java:63) at org.apache.calcite.rex.RexVisitor.visitList(RexVisitor.java:71) at org.apache.calcite.rex.RexInterpreter.visitCall(RexInterpreter.java:148) at org.apache.calcite.rex.RexInterpreter.visitCall(RexInterpreter.java:58) at org.apache.calcite.rex.RexCall.accept(RexCall.java:189) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4800) Add SortToSortUnifyRule in SubstitutionVisitor
xzh_dz created CALCITE-4800: --- Summary: Add SortToSortUnifyRule in SubstitutionVisitor Key: CALCITE-4800 URL: https://issues.apache.org/jira/browse/CALCITE-4800 Project: Calcite Issue Type: Improvement Reporter: xzh_dz In my project, there are more usage scenarios for materialized view recognition, and the `Sort Operator` can help sort data sets.But it has not been supported yet.A `Sort Operator` failed example can be reproduced as follows. {code:java} // code placeholder org.apache.calcite.test.MaterializedViewSubstitutionVisitorTest @Test void testSortToSort() { final String mv = "" + "select \"name\", \"deptno\"\n" + "from \"emps\"\n" + "order by \"deptno\""; final String query = "" + "select \"name\", \"deptno\"\n" + "from \"emps\"\n" + "order by \"deptno\" desc"; sql(mv, query).withChecker( resultContains("" + "EnumerableTableScan(table=[[hr, MV0]])")).ok(); } {code} Exception: {code:java} // code placeholder Materialized view failed to be matched by optimized results: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:116) at org.apache.calcite.test.AbstractMaterializedViewTest.access$000(AbstractMaterializedViewTest.java:67) at org.apache.calcite.test.AbstractMaterializedViewTest$Sql.ok(AbstractMaterializedViewTest.java:229) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at org.apache.calcite.util.ImmutableBeans.lambda$makeDef$3(ImmutableBeans.java:299) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4803) RelNode lost alias after remove Project operator
xzh_dz created CALCITE-4803: --- Summary: RelNode lost alias after remove Project operator Key: CALCITE-4803 URL: https://issues.apache.org/jira/browse/CALCITE-4803 Project: Calcite Issue Type: Improvement Reporter: xzh_dz In my project, I often use `RelOptRule` to optimize relational algebra. In the process of materialized view optimization, after removing the `Project operator`, I found that RelNode lost its alias and their relational algebra is not equivalent.Examples can be reproduced as follows. {code:java} // code placeholder org.apache.calcite.test.SqlToRelConverterTest @Test void testLoseAlias() { final String sql = "select ename as e, deptno as d, count(distinct empno) from emp group by ename, deptno"; final RelNode rel = tester.convertSqlToRel(sql).rel; // LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT(DISTINCT $2)]) // LogicalProject(E=[$1], D=[$7], EMPNO=[$0]) //LogicalTableScan(table=[[CATALOG, SALES, EMP]]) System.out.println(RelOptUtil.toString(rel)); final HepProgramBuilder programBuilder = HepProgram.builder(); programBuilder.addRuleInstance(CoreRules.AGGREGATE_PROJECT_MERGE); final HepPlanner planner = new HepPlanner(programBuilder.build()); planner.setRoot(rel); final RelNode relOpt = planner.findBestExp(); //LogicalAggregate(group=[{1, 7}], EXPR$2=[COUNT(DISTINCT $0)]) // LogicalTableScan(table=[[CATALOG, SALES, EMP]]) System.out.println(RelOptUtil.toString(relOpt)); // [ENAME, DEPTNO, EXPR$2] System.out.println(relOpt.getRowType().getFieldNames()); } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Created] (CALCITE-4804) Support Snapshot operator serialization and deserizalization
xzh_dz created CALCITE-4804: --- Summary: Support Snapshot operator serialization and deserizalization Key: CALCITE-4804 URL: https://issues.apache.org/jira/browse/CALCITE-4804 Project: Calcite Issue Type: Improvement Reporter: xzh_dz In my project, the dimension table has versions of the contents of the table. When I serialize the `Snapshot operator`, there are exceptions. Examples of exceptions can be reproduced as follows. {code:java} // code placeholder @Test void testSnapshot() { // Equivalent SQL: // SELECT * // FROM products_temporal FOR SYSTEM_TIME AS OF TIMESTAMP '2011-07-20 12:34:56' final RelBuilder builder = RelBuilder.create(config().build()); RelNode root = builder.scan("products_temporal") .snapshot( builder.getRexBuilder().makeTimestampLiteral( new TimestampString("2011-07-20 12:34:56"), 0)) .build(); RelJsonWriter jsonWriter = new RelJsonWriter(); root.explain(jsonWriter); String relJson = jsonWriter.asString(); String s = deserializeAndDumpToTextFormat(getSchema(root), relJson); }{code} Exception: {code:java} // code placeholder java.lang.RuntimeException: class does not have required constructor, class org.apache.calcite.rel.logical.LogicalSnapshot(RelInput)java.lang.RuntimeException: class does not have required constructor, class org.apache.calcite.rel.logical.LogicalSnapshot(RelInput)java.lang.RuntimeException: java.lang.RuntimeException: class does not have required constructor, class org.apache.calcite.rel.logical.LogicalSnapshot(RelInput) at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:193) at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:135) at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:153) at org.apache.calcite.test.RelBuilderTest.deserializeAndDump(RelBuilderTest.java:4005) at org.apache.calcite.test.RelBuilderTest.deserializeAndDumpToTextFormat(RelBuilderTest.java:3981) {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)