From f9f68aefd953e49d2102972e9eb99abbc5745fbd Mon Sep 17 00:00:00 2001 From: "clark.kang" Date: Mon, 23 Mar 2015 12:41:18 +0900 Subject: [PATCH] fix TAJO-1419 --- .../java/org/apache/tajo/SessionVars.java | 2 +- .../org/apache/tajo/cli/tsql/TestTajoCli.java | 42 ++++++++++++++++++- .../TestTajoCli/testHelpSessionVars.result | 2 +- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/tajo-common/src/main/java/org/apache/tajo/SessionVars.java b/tajo-common/src/main/java/org/apache/tajo/SessionVars.java index 5cca413c8e..0d2319e43b 100644 --- a/tajo-common/src/main/java/org/apache/tajo/SessionVars.java +++ b/tajo-common/src/main/java/org/apache/tajo/SessionVars.java @@ -71,7 +71,7 @@ public enum SessionVars implements ConfigKey { ON_ERROR_STOP(ConfVars.$CLI_ERROR_STOP, "tsql will exist if an error occurs.", CLI_SIDE_VAR), // Timezone & Date ---------------------------------------------------------- - TIMEZONE(ConfVars.$TIMEZONE, "Sets timezone", CLI_SIDE_VAR), + TIMEZONE(ConfVars.$TIMEZONE, "Sets timezone", DEFAULT), DATE_ORDER(ConfVars.$DATE_ORDER, "date order (default is YMD)", CLI_SIDE_VAR), // Locales and Character set ------------------------------------------------ diff --git a/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java b/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java index fdf9ca4e9f..d0e2677c50 100644 --- a/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java +++ b/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java @@ -366,7 +366,47 @@ public void testHelpSessionVars() throws Exception { assertOutputResult(new String(out.toByteArray())); } - @Test(timeout = 3000) + @Test + public void testTimeZoneSessionVars1() throws Exception { + tajoCli.executeMetaCommand("\\set TIMEZONE GMT+1"); + tajoCli.executeMetaCommand("\\set"); + String output = new String(out.toByteArray()); + assertTrue(output.contains("'TIMEZONE'='GMT+1'")); + } + + @Test + public void testTimeZoneSessionVars2() throws Exception { + tajoCli.executeScript("SET TIME ZONE 'GMT+2'"); + tajoCli.executeMetaCommand("\\set"); + String output = new String(out.toByteArray()); + assertTrue(output.contains("'TIMEZONE'='GMT+2'")); + } + + @Test + public void testTimeZoneTest1() throws Exception { + String tableName = "test1"; + tajoCli.executeMetaCommand("\\set TIMEZONE GMT+0"); + tajoCli.executeScript("create table " + tableName + " (col1 TIMESTAMP)"); + tajoCli.executeScript("insert into " + tableName + " select to_timestamp(0)"); + tajoCli.executeScript("select * from " + tableName); + String consoleResult = new String(out.toByteArray()); + tajoCli.executeScript("DROP TABLE " + tableName + " PURGE"); + assertTrue(consoleResult.contains("1970-01-01 00:00:00")); + } + + @Test + public void testTimeZoneTest2() throws Exception { + String tableName = "test1"; + tajoCli.executeMetaCommand("\\set TIMEZONE GMT+1"); + tajoCli.executeScript("create table " + tableName + " (col1 TIMESTAMP)"); + tajoCli.executeScript("insert into " + tableName + " select to_timestamp(0)"); + tajoCli.executeScript("select * from " + tableName); + String consoleResult = new String(out.toByteArray()); + tajoCli.executeScript("DROP TABLE " + tableName + " PURGE"); + assertTrue(consoleResult.contains("1970-01-01 01:00:00")); + } + + @Test(timeout = 3000) public void testNonForwardQueryPause() throws Exception { final String sql = "select * from default.lineitem"; TajoCli cli = null; diff --git a/tajo-core/src/test/resources/results/TestTajoCli/testHelpSessionVars.result b/tajo-core/src/test/resources/results/TestTajoCli/testHelpSessionVars.result index b5b7c229c9..bcd897078c 100644 --- a/tajo-core/src/test/resources/results/TestTajoCli/testHelpSessionVars.result +++ b/tajo-core/src/test/resources/results/TestTajoCli/testHelpSessionVars.result @@ -36,4 +36,4 @@ Available Session Variables: \set CODEGEN [true or false] - Runtime code generation enabled (experiment) \set ARITHABORT [true or false] - If true, a running query will be terminated when an overflow or divide-by-zero occurs. \set FETCH_ROWNUM [int value] - Sets the number of rows at a time from Master -\set DEBUG_ENABLED [true or false] - (debug only) debug mode enabled \ No newline at end of file +\set DEBUG_ENABLED [true or false] - (debug only) debug mode enabled