Return-Path: X-Original-To: apmail-tajo-commits-archive@minotaur.apache.org Delivered-To: apmail-tajo-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 987C611CE7 for ; Mon, 7 Jul 2014 05:05:15 +0000 (UTC) Received: (qmail 58991 invoked by uid 500); 7 Jul 2014 05:05:15 -0000 Delivered-To: apmail-tajo-commits-archive@tajo.apache.org Received: (qmail 58954 invoked by uid 500); 7 Jul 2014 05:05:15 -0000 Mailing-List: contact commits-help@tajo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tajo.apache.org Delivered-To: mailing list commits@tajo.apache.org Received: (qmail 58945 invoked by uid 99); 7 Jul 2014 05:05:15 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jul 2014 05:05:15 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id CDA429A0BF1; Mon, 7 Jul 2014 05:05:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hyunsik@apache.org To: commits@tajo.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: TAJO-905: When to_date() parses some date without day, the result will be wrong. (hyunsik) Date: Mon, 7 Jul 2014 05:05:14 +0000 (UTC) Repository: tajo Updated Branches: refs/heads/master 9fdd1ebe1 -> d84d5ca59 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/master Commit: d84d5ca59dc0cd3ad86cad6b9ec31681b8249e9f Parents: 9fdd1eb Author: Hyunsik Choi Authored: Mon Jul 7 14:04:42 2014 +0900 Committer: Hyunsik Choi 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