tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject tajo git commit: TAJO-1741: Two tables having same time zone display different timestamps.
Date Thu, 20 Aug 2015 06:11:51 GMT
Repository: tajo
Updated Branches:
  refs/heads/branch-0.11.0 b262291df -> 5ef0edb0d


TAJO-1741: Two tables having same time zone display different timestamps.

Closes #699

Signed-off-by: Hyunsik Choi <hyunsik@apache.org>


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

Branch: refs/heads/branch-0.11.0
Commit: 5ef0edb0d38117d78754aa3d1af1f0fc85e9cee9
Parents: b262291
Author: Jongyoung Park <eminency@gmail.com>
Authored: Thu Aug 20 15:09:19 2015 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Thu Aug 20 15:11:39 2015 +0900

----------------------------------------------------------------------
 CHANGES                                          |  3 +++
 .../org/apache/tajo/datum/TimestampDatum.java    |  7 +++++++
 .../tajo/engine/query/TestSelectQuery.java       | 19 +++++++++++++++++++
 .../datetime_table_timezoned_ddl2.sql            |  4 ++++
 .../testLoadIntoTimezonedTable.sql               |  2 ++
 .../text/TextFieldSerializerDeserializer.java    |  4 ++--
 6 files changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/5ef0edb0/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 3fe2931..75f5c1d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -227,6 +227,9 @@ Release 0.11.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1741: Two tables having same time zone display different timestamps.
+    (Contributed Jongyoung Park, committed by hyunsik)
+
     TAJO-1790: TestTajoClientV2::testExecuteQueryAsyncWithListener 
     occasionally is failed. (hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/5ef0edb0/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java b/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java
index a05f76c..aaf7beb 100644
--- a/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java
+++ b/tajo-common/src/main/java/org/apache/tajo/datum/TimestampDatum.java
@@ -123,6 +123,13 @@ public class TimestampDatum extends Datum {
     return asChars();
   }
 
+  /**
+   *
+   * @param tm TimeMEta
+   * @param timeZone Timezone
+   * @param includeTimeZone Add timezone if it is true. It is usually used for TIMEZONEZ
+   * @return A timestamp string
+   */
   public static String asChars(TimeMeta tm, TimeZone timeZone, boolean includeTimeZone) {
     DateTimeUtil.toUserTimezone(tm, timeZone);
     if (includeTimeZone) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/5ef0edb0/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
b/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
index 1637c85..3ce7b29 100644
--- a/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
+++ b/tajo-core-tests/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java
@@ -668,6 +668,25 @@ public class TestSelectQuery extends QueryTestCaseBase {
       testingCluster.getConfiguration().setSystemTimezone(TimeZone.getTimeZone("GMT"));
     }
   }
+
+  @Test
+  public void testLoadIntoTimezonedTable() throws Exception {
+    // Insert from timezoned table into another timezoned table
+
+    try {
+      executeDDL("datetime_table_timezoned_ddl.sql", "timezoned", "timezoned_load1");
+      executeDDL("datetime_table_timezoned_ddl2.sql", null, "timezoned_load2");
+      executeString("insert overwrite into timezoned_load2 select * from timezoned_load1");
+
+      ResultSet res = executeQuery();
+      assertResultSet(res, "testTimezonedTable3.result");
+      executeString("SET TIME ZONE 'GMT'");
+      cleanupQuery(res);
+    } finally {
+      executeString("DROP TABLE IF EXISTS timezoned_load1");
+      executeString("DROP TABLE IF EXISTS timezoned_load2 PURGE");
+    }
+  }
   
   @Test
   public void testMultiBytesDelimiter1() throws Exception {

http://git-wip-us.apache.org/repos/asf/tajo/blob/5ef0edb0/tajo-core-tests/src/test/resources/queries/TestSelectQuery/datetime_table_timezoned_ddl2.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSelectQuery/datetime_table_timezoned_ddl2.sql
b/tajo-core-tests/src/test/resources/queries/TestSelectQuery/datetime_table_timezoned_ddl2.sql
new file mode 100644
index 0000000..c02a653
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSelectQuery/datetime_table_timezoned_ddl2.sql
@@ -0,0 +1,4 @@
+CREATE TABLE ${0} (
+  t_timestamp  TIMESTAMP,
+  t_date    DATE
+) USING TEXT WITH ('timezone' = 'GMT+9')

http://git-wip-us.apache.org/repos/asf/tajo/blob/5ef0edb0/tajo-core-tests/src/test/resources/queries/TestSelectQuery/testLoadIntoTimezonedTable.sql
----------------------------------------------------------------------
diff --git a/tajo-core-tests/src/test/resources/queries/TestSelectQuery/testLoadIntoTimezonedTable.sql
b/tajo-core-tests/src/test/resources/queries/TestSelectQuery/testLoadIntoTimezonedTable.sql
new file mode 100644
index 0000000..733e4da
--- /dev/null
+++ b/tajo-core-tests/src/test/resources/queries/TestSelectQuery/testLoadIntoTimezonedTable.sql
@@ -0,0 +1,2 @@
+SET TIME ZONE 'GMT+9';
+SELECT * FROM timezoned_load2;

http://git-wip-us.apache.org/repos/asf/tajo/blob/5ef0edb0/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
index d7a43e1..086ad77 100644
--- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
+++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
@@ -124,7 +124,7 @@ public class TextFieldSerializerDeserializer implements FieldSerializerDeseriali
         break;
       case TIME:
         if (hasTimezone) {
-          bytes = TimeDatum.asChars(tuple.getTimeDate(columnIndex), timezone, true).getBytes(Bytes.UTF8_CHARSET);
+          bytes = TimeDatum.asChars(tuple.getTimeDate(columnIndex), timezone, false).getBytes(Bytes.UTF8_CHARSET);
         } else {
           bytes = tuple.getTextBytes(columnIndex);
         }
@@ -133,7 +133,7 @@ public class TextFieldSerializerDeserializer implements FieldSerializerDeseriali
         break;
       case TIMESTAMP:
         if (hasTimezone) {
-          bytes = TimestampDatum.asChars(tuple.getTimeDate(columnIndex), timezone, true).getBytes(Bytes.UTF8_CHARSET);
+          bytes = TimestampDatum.asChars(tuple.getTimeDate(columnIndex), timezone, false).getBytes(Bytes.UTF8_CHARSET);
         } else {
           bytes = tuple.getTextBytes(columnIndex);
         }


Mime
View raw message