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/28 18:06:43 UTC

[calcite] branch master updated (ad3153c -> 2e37b75)

This is an automated email from the ASF dual-hosted git repository.

hyuan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


    omit ad3153c  [CALCITE-3738] Missing order by logical plan for insert statement
     new 2e37b75  [CALCITE-3738] Missing order by logical plan for INSERT statement

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (ad3153c)
            \
             N -- N -- N   refs/heads/master (2e37b75)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:


[calcite] 01/01: [CALCITE-3738] Missing order by logical plan for INSERT statement

Posted by hy...@apache.org.
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

commit 2e37b752d5cfd29a4b7b77d0d70a33f52988f726
Author: pengzhiwei <pe...@icloud.com>
AuthorDate: Wed Jan 15 19:01:05 2020 +0800

    [CALCITE-3738] Missing order by logical plan for INSERT statement
---
 .../apache/calcite/sql2rel/SqlToRelConverter.java  |  2 +-
 .../apache/calcite/test/SqlToRelConverterTest.java | 12 +++++++++
 .../apache/calcite/test/SqlToRelConverterTest.xml  | 30 ++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
index 928c0dc..c3d74e2 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -3309,7 +3309,7 @@ public class SqlToRelConverter {
         validator.getValidatedNodeType(call);
     assert targetRowType != null;
     RelNode sourceRel =
-        convertQueryRecursive(call.getSource(), false, targetRowType).project();
+        convertQueryRecursive(call.getSource(), true, targetRowType).project();
     RelNode massagedRel = convertColumnList(call, sourceRel);
 
     return createModify(targetTable, massagedRel);
diff --git a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
index 7a01058..9eb3ce6 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
@@ -2222,6 +2222,18 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
     sql(sql).with(getExtendedTester()).ok();
   }
 
+  @Test public void testInsertWithSort() {
+    final String sql = "insert into empnullables (empno, ename) "
+        + "select deptno, ename from emp order by ename";
+    sql(sql).ok();
+  }
+
+  @Test public void testInsertWithLimit() {
+    final String sql = "insert into empnullables (empno, ename) "
+        + "select deptno, ename from emp order by ename limit 10";
+    sql(sql).ok();
+  }
+
   @Test public void testDelete() {
     final String sql = "delete from emp";
     sql(sql).ok();
diff --git a/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml b/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
index 98eab14..7760390 100644
--- a/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
@@ -3845,6 +3845,36 @@ LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], f
 ]]>
         </Resource>
     </TestCase>
+    <TestCase name="testInsertWithSort">
+        <Resource name="sql">
+            <![CDATA[insert into empnullables (empno, ename)
+ select deptno, ename from emp order by ename]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
+  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[null:INTEGER], SLACKER=[null:BOOLEAN])
+    LogicalSort(sort0=[$1], dir0=[ASC])
+      LogicalProject(DEPTNO=[$7], ENAME=[$1])
+        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
+    <TestCase name="testInsertWithLimit">
+        <Resource name="sql">
+            <![CDATA[insert into empnullables (empno, ename)
+ select deptno, ename from emp order by ename limit 10]]>
+        </Resource>
+        <Resource name="plan">
+            <![CDATA[
+LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
+  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[null:INTEGER], SLACKER=[null:BOOLEAN])
+    LogicalSort(sort0=[$1], dir0=[ASC], fetch=[10])
+      LogicalProject(DEPTNO=[$7], ENAME=[$1])
+        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+]]>
+        </Resource>
+    </TestCase>
     <TestCase name="testInsertBindSubset">
         <Resource name="sql">
             <![CDATA[insert into empnullables