You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by ja...@apache.org on 2014/06/02 18:51:25 UTC
[4/6] git commit: DRILL-818: Fix output type while adding date and
interval types.
DRILL-818: Fix output type while adding date and interval types.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/292765e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/292765e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/292765e7
Branch: refs/heads/master
Commit: 292765e7211d6ddddb64e67bdcff64829a60a615
Parents: d52e325
Author: Mehant Baid <me...@gmail.com>
Authored: Sun Jun 1 15:29:32 2014 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Mon Jun 2 09:13:07 2014 -0700
----------------------------------------------------------------------
.../DateIntervalArithmeticFunctions.java | 4 ++++
.../drill/exec/record/vector/TestDateTypes.java | 2 +-
.../org/apache/drill/jdbc/test/TestJdbcQuery.java | 15 +++++++++++++--
3 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/292765e7/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java
index 9103a86..4fbfdf9 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java
@@ -88,7 +88,11 @@ public class ${datetype}${intervaltype}Functions {
@Param ${datetype}Holder left;
@Param ${intervaltype}Holder right;
@Workspace org.joda.time.MutableDateTime temp;
+ <#if datetype == "Date" && (intervaltype.startsWith("Interval"))>
+ @Output TimeStampHolder out;
+ <#else>
@Output ${datetype}Holder out;
+ </#if>
public void setup(RecordBatch incoming) {
<#if datetype == "TimeStampTZ">
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/292765e7/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java
index adae024..f4fd7ae 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java
@@ -293,7 +293,7 @@ public class TestDateTypes extends PopUnitTestBase {
ValueVector.Accessor accessor = v.getValueVector().getAccessor();
- assertEquals((accessor.getObject(0).toString()), ("2008-03-27"));
+ assertEquals((accessor.getObject(0).toString()), ("2008-03-27 00:00:00.000"));
}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/292765e7/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
index e684228..088191c 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
@@ -44,6 +44,7 @@ import org.junit.rules.TestRule;
import com.google.common.base.Function;
import com.google.common.base.Stopwatch;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -764,7 +765,9 @@ import static org.junit.Assert.fail;
// show tables on view
ResultSet resultSet = statement.executeQuery("select date '2008-2-23', time '12:23:34', timestamp '2008-2-23 12:23:34.456', " +
- "interval '1' year, interval '2' day " +
+ "interval '1' year, interval '2' day, " +
+ "date_add(date '2008-2-23', interval '1 10:20:30' day to second), " +
+ "date_add(date '2010-2-23', 1) " +
"from cp.`employee.json` limit 1");
java.sql.Date date = resultSet.getDate(1);
@@ -772,9 +775,17 @@ import static org.junit.Assert.fail;
java.sql.Timestamp ts = resultSet.getTimestamp(3);
String intervalYear = resultSet.getString(4);
String intervalDay = resultSet.getString(5);
+ java.sql.Timestamp ts1 = resultSet.getTimestamp(6);
+ java.sql.Date date1 = resultSet.getDate(7);
+
+ java.sql.Timestamp result = java.sql.Timestamp.valueOf("2008-2-24 10:20:30");
+ java.sql.Date result1 = java.sql.Date.valueOf("2010-2-24");
+ assertEquals(ts1, result);
+ assertEquals(date1, result1);
System.out.println("Date: " + date.toString() + " time: " + time.toString() + " timestamp: " + ts.toString() +
- "\ninterval year: " + intervalYear + " intervalDay: " + intervalDay);
+ "\ninterval year: " + intervalYear + " intervalDay: " + intervalDay +
+ " date_interval_add: " + ts1.toString() + "date_int_add: " + date1.toString());
statement.close();
return null;