[
https://issues.apache.org/jira/browse/CALCITE-3644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17005966#comment-17005966
]
xzh_dz edited comment on CALCITE-3644 at 12/31/19 7:51 AM:
-----------------------------------------------------------
[[email protected]] Thanks for review, root cause is `target.rowType` and
`queryInputExplained0.right` have different types.
queryInputExplained0.right:
!screenshot-1.png!
target.rowType:
!screenshot-2.png!
When we try to generate compenRexProgram, it will fail because of different
RelDataTypes.
!screenshot-3.png!
When LogicalUnion is generated, rowType equal to null , LogicalUnion try to get
its RowType by `deriveRowType()`.
{code:java}
public final RelDataType getRowType() {
if (rowType == null) {
rowType = deriveRowType();
assert rowType != null : this;
}
return rowType;
}
{code}
`VARCHAR` is generated by `java.lang.String`#getSqlTypeName().
was (Author: xzh_dz):
Thanks, root cause is `target.rowType` and `queryInputExplained0.right` have
different types.
queryInputExplained0.right:
!screenshot-1.png!
target.rowType:
!screenshot-2.png!
When we try to generate compenRexProgram, it will fail because of different
RelDataTypes.
!screenshot-3.png!
When LogicalUnion is generated, rowType equal to null , LogicalUnion try to get
its RowType by `deriveRowType()`.
{code:java}
public final RelDataType getRowType() {
if (rowType == null) {
rowType = deriveRowType();
assert rowType != null : this;
}
return rowType;
}
{code}
`VARCHAR` is generated by `java.lang.String`#getSqlTypeName().
> Calc on the Intersect 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
> Priority: Major
> Labels: pull-request-available
> Attachments: screenshot-1.png, screenshot-2.png, screenshot-3.png
>
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> {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"
> <Click to see difference>
> 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)