You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by ru...@apache.org on 2019/07/25 06:59:53 UTC
[calcite] branch master updated: [CALCITE-3209] When calling
MutableMultiRel::setInput, exception thrown (Jin Xing)
This is an automated email from the ASF dual-hosted git repository.
rubenql pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 9ba140e [CALCITE-3209] When calling MutableMultiRel::setInput, exception thrown (Jin Xing)
9ba140e is described below
commit 9ba140ef66ad1e048789532211ddf8b3ca1cf8ec
Author: jinxing <ji...@gmail.com>
AuthorDate: Wed Jul 24 15:47:04 2019 +0800
[CALCITE-3209] When calling MutableMultiRel::setInput, exception thrown (Jin Xing)
---
.../calcite/rel/mutable/MutableMultiRel.java | 4 ++--
.../org/apache/calcite/test/MutableRelTest.java | 27 ++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/rel/mutable/MutableMultiRel.java b/core/src/main/java/org/apache/calcite/rel/mutable/MutableMultiRel.java
index 05ba762..ad660f0 100644
--- a/core/src/main/java/org/apache/calcite/rel/mutable/MutableMultiRel.java
+++ b/core/src/main/java/org/apache/calcite/rel/mutable/MutableMultiRel.java
@@ -20,9 +20,9 @@ import org.apache.calcite.linq4j.Ord;
import org.apache.calcite.plan.RelOptCluster;
import org.apache.calcite.rel.type.RelDataType;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
+import java.util.ArrayList;
import java.util.List;
/** Base Class for relations with three or more inputs */
@@ -32,7 +32,7 @@ abstract class MutableMultiRel extends MutableRel {
protected MutableMultiRel(RelOptCluster cluster,
RelDataType rowType, MutableRelType type, List<MutableRel> inputs) {
super(cluster, rowType, type);
- this.inputs = ImmutableList.copyOf(inputs);
+ this.inputs = new ArrayList<>(inputs);
for (Ord<MutableRel> input : Ord.zip(inputs)) {
input.e.parent = this;
input.e.ordinalInParent = input.i;
diff --git a/core/src/test/java/org/apache/calcite/test/MutableRelTest.java b/core/src/test/java/org/apache/calcite/test/MutableRelTest.java
index ed721b2..81b9d4b 100644
--- a/core/src/test/java/org/apache/calcite/test/MutableRelTest.java
+++ b/core/src/test/java/org/apache/calcite/test/MutableRelTest.java
@@ -38,6 +38,7 @@ import org.apache.calcite.util.Litmus;
import com.google.common.collect.ImmutableList;
+import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.Test;
@@ -175,6 +176,25 @@ public class MutableRelTest {
+ "intersect select * from emp where ename like 'John%'");
}
+ @Test public void testUpdateInputOfUnion() {
+ MutableRel mutableRel = createMutableRel(
+ "select sal from emp where deptno = 10"
+ + "union select sal from emp where ename like 'John%'");
+ MutableRel childMutableRel = createMutableRel(
+ "select sal from emp where deptno = 12");
+ mutableRel.setInput(0, childMutableRel);
+ String actual = RelOptUtil.toString(MutableRels.fromMutable(mutableRel));
+ String expected = ""
+ + "LogicalUnion(all=[false])\n"
+ + " LogicalProject(SAL=[$5])\n"
+ + " LogicalFilter(condition=[=($7, 12)])\n"
+ + " LogicalTableScan(table=[[CATALOG, SALES, EMP]])\n"
+ + " LogicalProject(SAL=[$5])\n"
+ + " LogicalFilter(condition=[LIKE($1, 'John%')])\n"
+ + " LogicalTableScan(table=[[CATALOG, SALES, EMP]])\n";
+ MatcherAssert.assertThat(actual, Matchers.isLinux(expected));
+ }
+
/** Verifies that after conversion to and from a MutableRel, the new
* RelNode remains identical to the original RelNode. */
private static void checkConvertMutableRel(String rel, String sql) {
@@ -234,6 +254,13 @@ public class MutableRelTest {
+ "Original rel: " + origRelStr + ";\nNew rel: " + newRelStr;
Assert.assertEquals(msg3, origRelStr, newRelStr);
}
+
+ private static MutableRel createMutableRel(String sql) {
+ final SqlToRelTestBase test = new SqlToRelTestBase() {
+ };
+ RelNode rel = test.createTester().convertSqlToRel(sql).rel;
+ return MutableRels.toMutable(rel);
+ }
}
// End MutableRelTest.java