You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by hy...@apache.org on 2020/01/27 23:07:19 UTC
[calcite] branch master updated: [CALCITE-3653] Support TableModify
in ToLogicalConverter (dz)
This is an automated email from the ASF dual-hosted git repository.
hyuan 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 93372e7 [CALCITE-3653] Support TableModify in ToLogicalConverter (dz)
93372e7 is described below
commit 93372e7de02f567fe6d026a6d28d3b6a254fd571
Author: dz <95...@qq.com>
AuthorDate: Tue Dec 31 12:04:20 2019 +0800
[CALCITE-3653] Support TableModify in ToLogicalConverter (dz)
---
.../org/apache/calcite/rel/logical/ToLogicalConverter.java | 10 ++++++++++
.../apache/calcite/rel/logical/ToLogicalConverterTest.java | 14 ++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/core/src/main/java/org/apache/calcite/rel/logical/ToLogicalConverter.java b/core/src/main/java/org/apache/calcite/rel/logical/ToLogicalConverter.java
index 5b262c2..a1206d7 100644
--- a/core/src/main/java/org/apache/calcite/rel/logical/ToLogicalConverter.java
+++ b/core/src/main/java/org/apache/calcite/rel/logical/ToLogicalConverter.java
@@ -33,6 +33,7 @@ import org.apache.calcite.rel.core.Join;
import org.apache.calcite.rel.core.Minus;
import org.apache.calcite.rel.core.Project;
import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rel.core.TableModify;
import org.apache.calcite.rel.core.TableScan;
import org.apache.calcite.rel.core.Uncollect;
import org.apache.calcite.rel.core.Union;
@@ -152,6 +153,15 @@ public class ToLogicalConverter extends RelShuttleImpl {
return LogicalCalc.create(visit(calc.getInput()), calc.getProgram());
}
+ if (relNode instanceof TableModify) {
+ final TableModify tableModify = (TableModify) relNode;
+ final RelNode input = visit(tableModify.getInput());
+ return LogicalTableModify.create(tableModify.getTable(),
+ tableModify.getCatalogReader(), input, tableModify.getOperation(),
+ tableModify.getUpdateColumnList(), tableModify.getSourceExpressionList(),
+ tableModify.isFlattened());
+ }
+
if (relNode instanceof EnumerableInterpreter
|| relNode instanceof JdbcToEnumerableConverter) {
return visit(((SingleRel) relNode).getInput());
diff --git a/core/src/test/java/org/apache/calcite/rel/logical/ToLogicalConverterTest.java b/core/src/test/java/org/apache/calcite/rel/logical/ToLogicalConverterTest.java
index a6f597a..b75c9cc 100644
--- a/core/src/test/java/org/apache/calcite/rel/logical/ToLogicalConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/logical/ToLogicalConverterTest.java
@@ -468,4 +468,18 @@ public class ToLogicalConverterTest {
+ " LogicalTableScan(table=[[foodmart, employee]])\n";
verify(rel(sql), expectedPhysial, expectedLogical);
}
+
+ @Test public void testTableModify() {
+ final String sql = "insert into \"employee\" select * from \"employee\"";
+ final String expectedPhysial = ""
+ + "JdbcToEnumerableConverter\n"
+ + " JdbcTableModify(table=[[foodmart, employee]], operation=[INSERT], flattened=[true])\n"
+ + " JdbcTableScan(table=[[foodmart, employee]])\n";
+ final String expectedLogical = ""
+ + "LogicalTableModify(table=[[foodmart, employee]], "
+ + "operation=[INSERT], flattened=[true])\n"
+ + " LogicalTableScan(table=[[foodmart, employee]])\n";
+ verify(rel(sql), expectedPhysial, expectedLogical);
+ }
+
}