You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Moritz Mack (Jira)" <ji...@apache.org> on 2023/02/01 08:40:00 UTC
[jira] [Comment Edited] (CALCITE-5503) Repeated nodes in a DAG plan are not reused in CheapestPlanReplacer
[ https://issues.apache.org/jira/browse/CALCITE-5503?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17682904#comment-17682904 ]
Moritz Mack edited comment on CALCITE-5503 at 2/1/23 8:39 AM:
--------------------------------------------------------------
[~julianhyde] Thanks for the pointer! Yes it's possible to verify using the Explain JSON format (y)
Though, by default the HEP planner program forces a tree and doesn't allow reuse ({*}noDag{*} flag). I would have to enable that flag to make the test below work, see below. What do you think?
{code:java}
--- a/core/src/main/java/org/apache/calcite/tools/Programs.java
+++ b/core/src/main/java/org/apache/calcite/tools/Programs.java
@@ -226,7 +226,7 @@ public static Program heuristicJoinOrder(
} public static Program calc(RelMetadataProvider metadataProvider) {
- return hep(RelOptRules.CALC_RULES, true, metadataProvider);
+ return hep(RelOptRules.CALC_RULES, false, metadataProvider);
}
{code}
Here's a successful Quidem test case with {*}noDag = false{*}.
{code:java}
!use scott
explain plan as json for
select * from emp where deptno = 10 and job = 'CLERK'
union all
select * from emp where deptno = 10 and job = 'CLERK';
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| PLAN |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"rels": [
{
"id": "0",
"relOp": "org.apache.calcite.adapter.enumerable.EnumerableTableScan",
"table": [
"scott",
"EMP"
],
"inputs": []
},
{
"id": "1",
"relOp": "org.apache.calcite.adapter.enumerable.EnumerableCalc",
"exprs": [
{
"input": 0,
"name": "$0"
},
{
"input": 1,
"name": "$1"
},
{
"input": 2,
"name": "$2"
},
{
"input": 3,
"name": "$3"
},
{
"input": 4,
"name": "$4"
},
{
"input": 5,
"name": "$5"
},
{
"input": 6,
"name": "$6"
},
{
"input": 7,
"name": "$7"
},
{
"op": {
"name": "CAST",
"kind": "CAST",
"syntax": "SPECIAL"
},
"operands": [
{
"input": 7,
"name": "$t7",
"type": {
"type": "TINYINT",
"nullable": true
}
}
],
"type": {
"type": "INTEGER",
"nullable": true
}
},
{
"literal": 10,
"type": {
"type": "INTEGER",
"nullable": false
}
},
{
"op": {
"name": "=",
"kind": "EQUALS",
"syntax": "BINARY"
},
"operands": [
{
"input": 8,
"name": "$t8",
"type": {
"type": "INTEGER",
"nullable": true
}
},
{
"input": 9,
"name": "$t9",
"type": {
"type": "INTEGER",
"nullable": false
}
}
]
},
{
"literal": "CLERK",
"type": {
"type": "VARCHAR",
"nullable": false,
"precision": 9
}
},
{
"op": {
"name": "=",
"kind": "EQUALS",
"syntax": "BINARY"
},
"operands": [
{
"input": 2,
"name": "$t2",
"type": {
"type": "VARCHAR",
"nullable": true,
"precision": 9
}
},
{
"input": 11,
"name": "$t11",
"type": {
"type": "VARCHAR",
"nullable": false,
"precision": 9
}
}
]
},
{
"op": {
"name": "AND",
"kind": "AND",
"syntax": "BINARY"
},
"operands": [
{
"input": 10,
"name": "$t10",
"type": {
"type": "BOOLEAN",
"nullable": true
}
},
{
"input": 12,
"name": "$t12",
"type": {
"type": "BOOLEAN",
"nullable": true
}
}
]
}
],
"projects": [
{
"input": 0,
"name": "$t0",
"type": {
"type": "SMALLINT",
"nullable": false
}
},
{
"input": 1,
"name": "$t1",
"type": {
"type": "VARCHAR",
"nullable": true,
"precision": 10
}
},
{
"input": 2,
"name": "$t2",
"type": {
"type": "VARCHAR",
"nullable": true,
"precision": 9
}
},
{
"input": 3,
"name": "$t3",
"type": {
"type": "SMALLINT",
"nullable": true
}
},
{
"input": 4,
"name": "$t4",
"type": {
"type": "DATE",
"nullable": true
}
},
{
"input": 5,
"name": "$t5",
"type": {
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2
}
},
{
"input": 6,
"name": "$t6",
"type": {
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2
}
},
{
"input": 7,
"name": "$t7",
"type": {
"type": "TINYINT",
"nullable": true
}
}
],
"condition": {
"input": 13,
"name": "$t13",
"type": {
"type": "BOOLEAN",
"nullable": true
}
},
"inputRowType": {
"fields": [
{
"type": "SMALLINT",
"nullable": false,
"name": "EMPNO"
},
{
"type": "VARCHAR",
"nullable": true,
"precision": 10,
"name": "ENAME"
},
{
"type": "VARCHAR",
"nullable": true,
"precision": 9,
"name": "JOB"
},
{
"type": "SMALLINT",
"nullable": true,
"name": "MGR"
},
{
"type": "DATE",
"nullable": true,
"name": "HIREDATE"
},
{
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2,
"name": "SAL"
},
{
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2,
"name": "COMM"
},
{
"type": "TINYINT",
"nullable": true,
"name": "DEPTNO"
}
],
"nullable": false
},
"outputRowType": {
"fields": [
{
"type": "SMALLINT",
"nullable": false,
"name": "EMPNO"
},
{
"type": "VARCHAR",
"nullable": true,
"precision": 10,
"name": "ENAME"
},
{
"type": "VARCHAR",
"nullable": true,
"precision": 9,
"name": "JOB"
},
{
"type": "SMALLINT",
"nullable": true,
"name": "MGR"
},
{
"type": "DATE",
"nullable": true,
"name": "HIREDATE"
},
{
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2,
"name": "SAL"
},
{
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2,
"name": "COMM"
},
{
"type": "TINYINT",
"nullable": true,
"name": "DEPTNO"
}
],
"nullable": false
}
},
{
"id": "2",
"relOp": "org.apache.calcite.adapter.enumerable.EnumerableUnion",
"all": true,
"inputs": [
"1",
"1"
]
}
]
} |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
(1 row)
!ok
{code}
was (Author: mosche):
[~julianhyde] Thanks for the pointer! Yes it's possible to verify using the Explain JSON format (y)
Though, by default the HEP planner program forces a tree and doesn't allow reuse (noDag flag). I would have to enable that flag to make the test below work, see below. What do you think?
{code:java}
--- a/core/src/main/java/org/apache/calcite/tools/Programs.java
+++ b/core/src/main/java/org/apache/calcite/tools/Programs.java
@@ -226,7 +226,7 @@ public static Program heuristicJoinOrder(
} public static Program calc(RelMetadataProvider metadataProvider) {
- return hep(RelOptRules.CALC_RULES, true, metadataProvider);
+ return hep(RelOptRules.CALC_RULES, false, metadataProvider);
}
{code}
Here's the Quidem test case with doDag = true.
{code:java}
!use scott
explain plan as json for
select * from emp where deptno = 10 and job = 'CLERK'
union all
select * from emp where deptno = 10 and job = 'CLERK';
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| PLAN |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"rels": [
{
"id": "0",
"relOp": "org.apache.calcite.adapter.enumerable.EnumerableTableScan",
"table": [
"scott",
"EMP"
],
"inputs": []
},
{
"id": "1",
"relOp": "org.apache.calcite.adapter.enumerable.EnumerableCalc",
"exprs": [
{
"input": 0,
"name": "$0"
},
{
"input": 1,
"name": "$1"
},
{
"input": 2,
"name": "$2"
},
{
"input": 3,
"name": "$3"
},
{
"input": 4,
"name": "$4"
},
{
"input": 5,
"name": "$5"
},
{
"input": 6,
"name": "$6"
},
{
"input": 7,
"name": "$7"
},
{
"op": {
"name": "CAST",
"kind": "CAST",
"syntax": "SPECIAL"
},
"operands": [
{
"input": 7,
"name": "$t7",
"type": {
"type": "TINYINT",
"nullable": true
}
}
],
"type": {
"type": "INTEGER",
"nullable": true
}
},
{
"literal": 10,
"type": {
"type": "INTEGER",
"nullable": false
}
},
{
"op": {
"name": "=",
"kind": "EQUALS",
"syntax": "BINARY"
},
"operands": [
{
"input": 8,
"name": "$t8",
"type": {
"type": "INTEGER",
"nullable": true
}
},
{
"input": 9,
"name": "$t9",
"type": {
"type": "INTEGER",
"nullable": false
}
}
]
},
{
"literal": "CLERK",
"type": {
"type": "VARCHAR",
"nullable": false,
"precision": 9
}
},
{
"op": {
"name": "=",
"kind": "EQUALS",
"syntax": "BINARY"
},
"operands": [
{
"input": 2,
"name": "$t2",
"type": {
"type": "VARCHAR",
"nullable": true,
"precision": 9
}
},
{
"input": 11,
"name": "$t11",
"type": {
"type": "VARCHAR",
"nullable": false,
"precision": 9
}
}
]
},
{
"op": {
"name": "AND",
"kind": "AND",
"syntax": "BINARY"
},
"operands": [
{
"input": 10,
"name": "$t10",
"type": {
"type": "BOOLEAN",
"nullable": true
}
},
{
"input": 12,
"name": "$t12",
"type": {
"type": "BOOLEAN",
"nullable": true
}
}
]
}
],
"projects": [
{
"input": 0,
"name": "$t0",
"type": {
"type": "SMALLINT",
"nullable": false
}
},
{
"input": 1,
"name": "$t1",
"type": {
"type": "VARCHAR",
"nullable": true,
"precision": 10
}
},
{
"input": 2,
"name": "$t2",
"type": {
"type": "VARCHAR",
"nullable": true,
"precision": 9
}
},
{
"input": 3,
"name": "$t3",
"type": {
"type": "SMALLINT",
"nullable": true
}
},
{
"input": 4,
"name": "$t4",
"type": {
"type": "DATE",
"nullable": true
}
},
{
"input": 5,
"name": "$t5",
"type": {
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2
}
},
{
"input": 6,
"name": "$t6",
"type": {
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2
}
},
{
"input": 7,
"name": "$t7",
"type": {
"type": "TINYINT",
"nullable": true
}
}
],
"condition": {
"input": 13,
"name": "$t13",
"type": {
"type": "BOOLEAN",
"nullable": true
}
},
"inputRowType": {
"fields": [
{
"type": "SMALLINT",
"nullable": false,
"name": "EMPNO"
},
{
"type": "VARCHAR",
"nullable": true,
"precision": 10,
"name": "ENAME"
},
{
"type": "VARCHAR",
"nullable": true,
"precision": 9,
"name": "JOB"
},
{
"type": "SMALLINT",
"nullable": true,
"name": "MGR"
},
{
"type": "DATE",
"nullable": true,
"name": "HIREDATE"
},
{
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2,
"name": "SAL"
},
{
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2,
"name": "COMM"
},
{
"type": "TINYINT",
"nullable": true,
"name": "DEPTNO"
}
],
"nullable": false
},
"outputRowType": {
"fields": [
{
"type": "SMALLINT",
"nullable": false,
"name": "EMPNO"
},
{
"type": "VARCHAR",
"nullable": true,
"precision": 10,
"name": "ENAME"
},
{
"type": "VARCHAR",
"nullable": true,
"precision": 9,
"name": "JOB"
},
{
"type": "SMALLINT",
"nullable": true,
"name": "MGR"
},
{
"type": "DATE",
"nullable": true,
"name": "HIREDATE"
},
{
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2,
"name": "SAL"
},
{
"type": "DECIMAL",
"nullable": true,
"precision": 7,
"scale": 2,
"name": "COMM"
},
{
"type": "TINYINT",
"nullable": true,
"name": "DEPTNO"
}
],
"nullable": false
}
},
{
"id": "2",
"relOp": "org.apache.calcite.adapter.enumerable.EnumerableUnion",
"all": true,
"inputs": [
"1",
"1"
]
}
]
} |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
(1 row)
!ok
{code}
> Repeated nodes in a DAG plan are not reused in CheapestPlanReplacer
> -------------------------------------------------------------------
>
> Key: CALCITE-5503
> URL: https://issues.apache.org/jira/browse/CALCITE-5503
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Moritz Mack
> Assignee: Moritz Mack
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 50m
> Remaining Estimate: 0h
>
> When using CheapestPlanReplacer, semantics of a RelNode tree change if it contains the same node multiple times in case this node has inputs itself that have to be replaced. During replacement such nodes get copied on each occurrence.
> Instead CheapestPlanReplacer should memoize previously visited nodes and emit the same result again in the that case.
> The test case below illustrates the issue and fails on the current main branch.
>
> {code:java}
> @Test void testMemoizeInputRelNodes() {
> VolcanoPlanner planner = new VolcanoPlanner();
> planner.addRelTraitDef(ConventionTraitDef.INSTANCE);
> RelOptCluster cluster = newCluster(planner);
> // The rule that triggers the assert rule
> planner.addRule(PhysLeafRule.INSTANCE);
> planner.addRule(GoodSingleRule.INSTANCE);
> // Leaf RelNode
> NoneLeafRel leafRel = new NoneLeafRel(cluster, "a");
> RelNode leafPhy = planner
> .changeTraits(leafRel, cluster.traitSetOf(PHYS_CALLING_CONVENTION));
> // RelNode with leaf RelNode as single input
> NoneSingleRel singleRel = new NoneSingleRel(cluster, leafPhy);
> RelNode singlePhy = planner
> .changeTraits(singleRel, cluster.traitSetOf(PHYS_CALLING_CONVENTION));
> // Binary RelNode with identical input on either side
> PhysBiRel parent = new PhysBiRel(
> cluster, cluster.traitSetOf(PHYS_CALLING_CONVENTION), singlePhy, singlePhy);
> planner.setRoot(parent);
> RelNode result = planner.chooseDelegate().findBestExp();
> // Expect inputs to remain identical
> assertEquals(result.getInput(0), result.getInput(1));
> } {code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)