tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [47/50] [abbrv] git commit: TAJO-905: When to_date() parses some date without day, the result will be wrong. (hyunsik)
Date Wed, 09 Jul 2014 04:11:04 GMT
TAJO-905: When to_date() parses some date without day, the result will be wrong. (hyunsik)

Closes #57


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

Branch: refs/heads/window_function
Commit: d84d5ca59dc0cd3ad86cad6b9ec31681b8249e9f
Parents: 9fdd1eb
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Mon Jul 7 14:04:42 2014 +0900
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Mon Jul 7 14:04:42 2014 +0900

----------------------------------------------------------------------
 CHANGES                                                         | 3 +++
 .../main/java/org/apache/tajo/util/datetime/DateTimeFormat.java | 5 +++++
 .../org/apache/tajo/engine/function/TestDateTimeFunctions.java  | 2 ++
 3 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/d84d5ca5/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 74db949..74958dd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -74,6 +74,9 @@ Release 0.9.0 - unreleased
 
   BUG FIXES
 
+    TAJO-905: When to_date() parses some date without day, the result will be 
+    wrong. (hyunsik)
+
     TAJO-898: Left outer join with union returns empty result. 
     (Hyoungjun Kim via hyunsik)
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/d84d5ca5/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeFormat.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeFormat.java b/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeFormat.java
index bc8435b..fa5b458 100644
--- a/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeFormat.java
+++ b/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeFormat.java
@@ -596,6 +596,11 @@ public class DateTimeFormat {
     //TODO consider TimeZone
     doToTimestamp(dateText, formatText, tm);
 
+    // when we parse some date without day like '2014-04', we should set day to 1.
+    if (tm.dayOfMonth == 0) {
+      tm.dayOfMonth = 1;
+    }
+
     if (tm.dayOfYear > 0 && tm.dayOfMonth > 0) {
       tm.dayOfYear = 0;
     }

http://git-wip-us.apache.org/repos/asf/tajo/blob/d84d5ca5/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
b/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
index ef691f7..ab8772b 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
@@ -312,6 +312,8 @@ public class TestDateTimeFunctions extends ExprTestBase {
     testSimpleEval("select to_date('2014-01-04', 'YYYY-MM-DD')", new String[]{"2014-01-04"});
     testSimpleEval("select to_date('2014-01-04', 'YYYY-MM-DD') + interval '1 day'",
         new String[]{"2014-01-05 00:00:00" + getUserTimeZoneDisplay()});
+
+    testSimpleEval("SELECT to_date('201404', 'yyyymm');", new String[]{"2014-04-01"});
   }
 
   @Test


Mime
View raw message