Repository: tajo Updated Branches: refs/heads/master 5852cb3b9 -> 2d2f192d7
TAJO-1741: Two tables having same time zone display different timestamps. Closes #699 Signed-off-by: Hyunsik Choi <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/2d2f192d Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/2d2f192d Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/2d2f192d Branch: refs/heads/master Commit: 2d2f192d78249d8acc812a1a3d08f5caceee9208 Parents: 5852cb3 Author: Jongyoung Park <[email protected]> Authored: Thu Aug 20 15:09:19 2015 +0900 Committer: Hyunsik Choi <[email protected]> Committed: Thu Aug 20 15:09:19 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/2d2f192d/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 5033f79..1c2a9e7 100644 --- a/CHANGES +++ b/CHANGES @@ -229,6 +229,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/2d2f192d/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/2d2f192d/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/2d2f192d/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/2d2f192d/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/2d2f192d/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); }
