drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject drill git commit: DRILL-3382: Fix IOOB error for CTAS order by statement.
Date Sat, 27 Jun 2015 06:23:24 GMT
Repository: drill
Updated Branches:
  refs/heads/master e347a5287 -> 53d09a0b9


DRILL-3382: Fix IOOB error for CTAS order by statement.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/53d09a0b
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/53d09a0b
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/53d09a0b

Branch: refs/heads/master
Commit: 53d09a0b9c5c9dbc7ee6642c3d2d9ac7f9bc0912
Parents: e347a52
Author: Jinfeng Ni <jni@apache.org>
Authored: Fri Jun 26 11:04:11 2015 -0700
Committer: Jinfeng Ni <jni@apache.org>
Committed: Fri Jun 26 16:29:32 2015 -0700

----------------------------------------------------------------------
 .../sql/handlers/CreateTableHandler.java        |  7 ++++--
 .../org/apache/drill/exec/sql/TestCTAS.java     | 25 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/53d09a0b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
index 5a0e40e..e39074e 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/CreateTableHandler.java
@@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.plan.RelTraitSet;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeField;
@@ -45,6 +46,7 @@ import org.apache.drill.exec.planner.logical.CreateTableEntry;
 import org.apache.drill.exec.planner.logical.DrillRel;
 import org.apache.drill.exec.planner.logical.DrillScreenRel;
 import org.apache.drill.exec.planner.logical.DrillWriterRel;
+import org.apache.drill.exec.planner.physical.DrillDistributionTrait;
 import org.apache.drill.exec.planner.physical.Prel;
 import org.apache.drill.exec.planner.physical.ProjectAllowDupPrel;
 import org.apache.drill.exec.planner.physical.ProjectPrel;
@@ -114,8 +116,9 @@ public class CreateTableHandler extends DefaultSqlHandler {
     final DrillRel topPreservedNameProj = queryRowType.getFieldCount() == convertedRelNode.getRowType().getFieldCount()
?
         addRenamedProject(convertedRelNode, queryRowType) : convertedRelNode;
 
-    final DrillWriterRel writerRel = new DrillWriterRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(),
-        topPreservedNameProj, schema.createNewTable(tableName, partitionColumns));
+    final RelTraitSet traits = convertedRelNode.getCluster().traitSet().plus(DrillRel.DRILL_LOGICAL);
+    final DrillWriterRel writerRel = new DrillWriterRel(convertedRelNode.getCluster(),
+        traits, topPreservedNameProj, schema.createNewTable(tableName, partitionColumns));
     return new DrillScreenRel(writerRel.getCluster(), writerRel.getTraitSet(), writerRel);
   }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/53d09a0b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
index aec2237..33288e3 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
@@ -188,6 +188,31 @@ public class TestCTAS extends BaseTestQuery {
     }
   }
 
+  @Test // DRILL-3382
+  public void ctasWithQueryOrderby() throws Exception {
+    final String newTblName = "ctasWithQueryOrderby";
+
+    try {
+      final String ctasQuery = String.format("CREATE TABLE %s.%s   " +
+          "AS SELECT n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` order by
n_nationkey",
+          TEMP_SCHEMA, newTblName);
+
+      test(ctasQuery);
+
+      final String selectFromCreatedTable = String.format(" select n_nationkey, n_name, n_comment
from %s.%s", TEMP_SCHEMA, newTblName);
+      final String baselineQuery = "select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet`
order by n_nationkey";
+
+      testBuilder()
+          .sqlQuery(selectFromCreatedTable)
+          .ordered()
+          .sqlBaselineQuery(baselineQuery)
+          .build()
+          .run();
+    } finally {
+      FileUtils.deleteQuietly(new File(getDfsTestTmpSchemaLocation(), newTblName));
+    }
+  }
+
   private static void ctasErrorTestHelper(final String ctasSql, final String expErrorMsg)
throws Exception {
     final String createTableSql = String.format(ctasSql, TEMP_SCHEMA, "testTableName");
     errorMsgTestHelper(createTableSql, expErrorMsg);


Mime
View raw message