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-4392: Fix CTAS partition to remove one unnecessary internal field in generated parquet files.
Date Fri, 19 Feb 2016 17:56:49 GMT
Repository: drill
Updated Branches:
  refs/heads/master 8126927fd -> 7d5a0a86e


DRILL-4392: Fix CTAS partition to remove one unnecessary internal field in generated parquet
files.


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

Branch: refs/heads/master
Commit: 7d5a0a86e36932726abee49aa4c29ea9cbd576e9
Parents: 8126927
Author: Jinfeng Ni <jni@apache.org>
Authored: Thu Feb 18 15:38:42 2016 -0800
Committer: Jinfeng Ni <jni@apache.org>
Committed: Fri Feb 19 07:38:28 2016 -0800

----------------------------------------------------------------------
 .../templates/EventBasedRecordWriter.java       |  2 +-
 .../exec/store/parquet/ParquetRecordWriter.java |  2 +-
 .../org/apache/drill/exec/sql/TestCTAS.java     | 25 ++++++++++++++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/7d5a0a86/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java b/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java
index c7676cb..584f4b6 100644
--- a/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java
+++ b/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java
@@ -79,7 +79,7 @@ public class EventBasedRecordWriter {
     try {
       int fieldId = 0;
       for (VectorWrapper w : batch) {
-        if (w.getField().getPath().equals(SchemaPath.getSimplePath(WriterPrel.PARTITION_COMPARATOR_FIELD)))
{
+        if (w.getField().getPath().equalsIgnoreCase(WriterPrel.PARTITION_COMPARATOR_FIELD))
{
           continue;
         }
         FieldReader reader = w.getValueVector().getReader();

http://git-wip-us.apache.org/repos/asf/drill/blob/7d5a0a86/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
index 8f4f5fd..3f2defd 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
@@ -181,7 +181,7 @@ public class ParquetRecordWriter extends ParquetOutputRecordWriter {
   private void newSchema() throws IOException {
     List<Type> types = Lists.newArrayList();
     for (MaterializedField field : batchSchema) {
-      if (field.getPath().equals(SchemaPath.getSimplePath(WriterPrel.PARTITION_COMPARATOR_FIELD)))
{
+      if (field.getPath().equalsIgnoreCase(WriterPrel.PARTITION_COMPARATOR_FIELD)) {
         continue;
       }
       types.add(getType(field));

http://git-wip-us.apache.org/repos/asf/drill/blob/7d5a0a86/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 33288e3..5294709 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
@@ -213,6 +213,31 @@ public class TestCTAS extends BaseTestQuery {
     }
   }
 
+  @Test // DRILL-4392
+  public void ctasWithPartition() throws Exception {
+    final String newTblName = "nation_ctas";
+
+    try {
+      final String ctasQuery = String.format("CREATE TABLE %s.%s   " +
+          "partition by (n_regionkey) AS SELECT n_nationkey, n_regionkey from cp.`tpch/nation.parquet`
order by n_nationkey limit 1",
+          TEMP_SCHEMA, newTblName);
+
+      test(ctasQuery);
+
+      final String selectFromCreatedTable = String.format(" select * from %s.%s", TEMP_SCHEMA,
newTblName);
+      final String baselineQuery = "select n_nationkey, n_regionkey from cp.`tpch/nation.parquet`
order by n_nationkey limit 1";
+
+      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