TAJO-1419: Tsql session command doesn't work.

Closes #452

Signed-off-by: Jihoon Son <[email protected]>


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

Branch: refs/heads/index_support
Commit: 2a5d9128702d5ef5ab16405c0e4f4b296fa1d896
Parents: f072979
Author: DaeMyung Kang <[email protected]>
Authored: Tue Apr 21 06:16:08 2015 +0900
Committer: Jihoon Son <[email protected]>
Committed: Tue Apr 21 06:16:08 2015 +0900

----------------------------------------------------------------------
 CHANGES                                         |  3 ++
 .../main/java/org/apache/tajo/SessionVars.java  |  2 +-
 .../org/apache/tajo/cli/tsql/TestTajoCli.java   | 40 ++++++++++++++++++++
 .../TestTajoCli/testHelpSessionVars.result      |  2 +-
 4 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/2a5d9128/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 8569456..ff88c59 100644
--- a/CHANGES
+++ b/CHANGES
@@ -102,6 +102,9 @@ Release 0.11.0 - unreleased
 
   BUG FIXES
 
+    TAJO-1419: Tsql session command doesn't work. (Contributed by DaeMyung 
Kang,
+    Committed by jihoon)
+
     TAJO-1481: Numeric conversion of Inet4 type should be considered as 
unsigned.
     (Contributed by navis, Committed by jihoon)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/2a5d9128/tajo-common/src/main/java/org/apache/tajo/SessionVars.java
----------------------------------------------------------------------
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 5cca413..0d2319e 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 ------------------------------------------------

http://git-wip-us.apache.org/repos/asf/tajo/blob/2a5d9128/tajo-core/src/test/java/org/apache/tajo/cli/tsql/TestTajoCli.java
----------------------------------------------------------------------
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 fdf9ca4..54e50fc 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,6 +366,46 @@ public class TestTajoCli {
     assertOutputResult(new String(out.toByteArray()));
   }
 
+  @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";

http://git-wip-us.apache.org/repos/asf/tajo/blob/2a5d9128/tajo-core/src/test/resources/results/TestTajoCli/testHelpSessionVars.result
----------------------------------------------------------------------
diff --git 
a/tajo-core/src/test/resources/results/TestTajoCli/testHelpSessionVars.result 
b/tajo-core/src/test/resources/results/TestTajoCli/testHelpSessionVars.result
index b5b7c22..bcd8970 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

Reply via email to