tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [05/14] git commit: TAJO-977: INSERT into a partitioned table as SELECT statement uses a wrong schema. (Hyoungjun Kim via hyunsik)
Date Fri, 01 Aug 2014 05:58:58 GMT
TAJO-977: INSERT into a partitioned table as SELECT statement uses a wrong schema. (Hyoungjun
Kim via hyunsik)

Closes #95


Project: http://git-wip-us.apache.org/repos/asf/tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/9880f06f
Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/9880f06f
Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/9880f06f

Branch: refs/heads/index_support
Commit: 9880f06fd9e13402593a48a834df972e5b170fe2
Parents: 72808e0
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Sat Jul 26 21:02:25 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Sat Jul 26 21:02:25 2014 +0900

----------------------------------------------------------------------
 CHANGES                                         |  7 +-
 .../planner/physical/ColPartitionStoreExec.java |  3 +-
 .../tajo/engine/query/TestInsertQuery.java      | 70 ++++++++++++++++++++
 3 files changed, 77 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/9880f06f/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 08cf60a..2e530af 100644
--- a/CHANGES
+++ b/CHANGES
@@ -97,8 +97,11 @@ Release 0.9.0 - unreleased
 
   BUG FIXES
 
-    TAJO-968: Self-Join query (including partitioned table) doesn't run unexpectedly 
-    using auto broadcast join. (jaewha)
+    TAJO-977: INSERT into a partitioned table as SELECT statement uses a wrong 
+    schema. (Hyoungjun Kim via hyunsik)
+
+    TAJO-968: Self-Join query (including partitioned table) doesn't run 
+    unexpectedly using auto broadcast join. (jaewha)
 
     TAJO-914: join queries with constant values can cause schema mismatch in
     logical plan. (hyunsik)

http://git-wip-us.apache.org/repos/asf/tajo/blob/9880f06f/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
index d292437..e90baff 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/ColPartitionStoreExec.java
@@ -38,7 +38,6 @@ import org.apache.tajo.storage.StorageUtil;
 import org.apache.tajo.worker.TaskAttemptContext;
 
 import java.io.IOException;
-import java.text.NumberFormat;
 
 public abstract class ColPartitionStoreExec extends UnaryPhysicalExec {
   private static Log LOG = LogFactory.getLog(ColPartitionStoreExec.class);
@@ -57,6 +56,8 @@ public abstract class ColPartitionStoreExec extends UnaryPhysicalExec {
 
     if (plan.getType() == NodeType.CREATE_TABLE) {
       this.outSchema = ((CreateTableNode)plan).getTableSchema();
+    } else if (plan.getType() == NodeType.INSERT) {
+      this.outSchema = ((InsertNode)plan).getTableSchema();
     }
 
     // set table meta

http://git-wip-us.apache.org/repos/asf/tajo/blob/9880f06f/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInsertQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInsertQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInsertQuery.java
index 4b48182..0d309c7 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInsertQuery.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInsertQuery.java
@@ -507,6 +507,76 @@ public class TestInsertQuery extends QueryTestCaseBase {
   }
 
   @Test
+  public final void testInsertOverwriteIntoParquet() throws Exception {
+    if (!testingCluster.isHCatalogStoreRunning()) {
+      executeString("create table parquet_table " +
+          "(l_orderkey int4, l_shipdate text, l_shipdate_function text) using parquet").close();
+
+      CatalogService catalog = testingCluster.getMaster().getCatalog();
+      assertTrue(catalog.existsTable(getCurrentDatabase(), "parquet_table"));
+
+      executeString(
+          "insert overwrite into parquet_table  " +
+              "select l_orderkey, l_shipdate, substr(l_shipdate, 1, 10) from default.lineitem").close();
+
+      TableDesc desc = catalog.getTableDesc(getCurrentDatabase(), "parquet_table");
+      if (!testingCluster.isHCatalogStoreRunning()) {
+        assertEquals(5, desc.getStats().getNumRows().intValue());
+      }
+
+      ResultSet res = executeString("select l_orderkey, l_shipdate, l_shipdate_function "
+
+          "from parquet_table ");
+
+      String expected = "l_orderkey,l_shipdate,l_shipdate_function\n" +
+          "-------------------------------\n" +
+          "1,1996-03-13,1996-03-13\n" +
+          "1,1996-04-12,1996-04-12\n" +
+          "2,1997-01-28,1997-01-28\n" +
+          "3,1994-02-02,1994-02-02\n" +
+          "3,1993-11-09,1993-11-09\n";
+
+      assertEquals(expected, resultSetToString(res));
+
+      executeString("DROP TABLE parquet_table PURGE");
+    }
+  }
+
+  @Test
+  public final void testInsertOverwriteIntoPartitionedParquet() throws Exception {
+    if (!testingCluster.isHCatalogStoreRunning()) {
+      executeString("create table parquet_table " +
+          "(l_orderkey int4, l_shipdate_function text) using parquet partition by column
(l_shipdate text)").close();
+
+      CatalogService catalog = testingCluster.getMaster().getCatalog();
+      assertTrue(catalog.existsTable(getCurrentDatabase(), "parquet_table"));
+
+      executeString(
+          "insert overwrite into parquet_table  " +
+              "select l_orderkey, substr(l_shipdate, 1, 10), l_shipdate from default.lineitem").close();
+
+      TableDesc desc = catalog.getTableDesc(getCurrentDatabase(), "parquet_table");
+      if (!testingCluster.isHCatalogStoreRunning()) {
+        assertEquals(5, desc.getStats().getNumRows().intValue());
+      }
+
+      ResultSet res = executeString("select l_orderkey, l_shipdate, l_shipdate_function "
+
+          "from parquet_table ");
+
+      String expected = "l_orderkey,l_shipdate,l_shipdate_function\n" +
+          "-------------------------------\n" +
+          "3,1993-11-09,1993-11-09\n" +
+          "3,1994-02-02,1994-02-02\n" +
+          "1,1996-03-13,1996-03-13\n" +
+          "1,1996-04-12,1996-04-12\n" +
+          "2,1997-01-28,1997-01-28\n";
+
+      assertEquals(expected, resultSetToString(res));
+
+      executeString("DROP TABLE parquet_table PURGE");
+    }
+  }
+
+  @Test
   public final void testInsertOverwriteWithDatabase() throws Exception {
     ResultSet res = executeFile("table1_ddl.sql");
     res.close();


Mime
View raw message