drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject drill git commit: DRILL-3943: In constant folding, when the the data type of the return value is TimeStamp, generate TimeStamp Literal
Date Fri, 16 Oct 2015 21:59:39 GMT
Repository: drill
Updated Branches:
  refs/heads/master 12fb9ac11 -> 826144d89


DRILL-3943: In constant folding, when the the data type of the return value is TimeStamp,
generate TimeStamp Literal

This closes #206


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

Branch: refs/heads/master
Commit: 826144d89391dbadfc7fec84e633359c602bcd5a
Parents: 12fb9ac
Author: Hsuan-Yi Chu <hsuanyi@usc.edu>
Authored: Wed Oct 14 20:55:34 2015 -0700
Committer: Jason Altekruse <altekrusejason@gmail.com>
Committed: Fri Oct 16 14:54:35 2015 -0700

----------------------------------------------------------------------
 .../exec/planner/logical/DrillConstExecutor.java      |  6 ++----
 .../apache/drill/exec/fn/impl/TestCastFunctions.java  | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/826144d8/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillConstExecutor.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillConstExecutor.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillConstExecutor.java
index 15258ef..78d2701 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillConstExecutor.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillConstExecutor.java
@@ -278,10 +278,8 @@ public class DrillConstExecutor implements RelOptPlanner.Executor {
                 false));
             break;
           case TIMESTAMP:
-            reducedValues.add(rexBuilder.makeLiteral(
-                new DateTime(((TimeStampHolder)output).value, DateTimeZone.UTC).toCalendar(null),
-                createCalciteTypeWithNullability(typeFactory, SqlTypeName.TIMESTAMP, newCall.getType().isNullable()),
-                false));
+            reducedValues.add(rexBuilder.makeTimestampLiteral(
+                new DateTime(((TimeStampHolder)output).value, DateTimeZone.UTC).toCalendar(null),
0));
             break;
           case INTERVALYEAR:
             reducedValues.add(rexBuilder.makeLiteral(

http://git-wip-us.apache.org/repos/asf/drill/blob/826144d8/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java
index 3ba8743..286c1d4 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java
@@ -52,4 +52,18 @@ public class TestCastFunctions extends BaseTestQuery {
       .build().run();
   }
 
+  @Test // DRILL-2808
+  public void testCastByConstantFolding() throws Exception {
+    final String query = "SELECT count(DISTINCT employee_id) as col1, " +
+        "count((to_number(date_diff(now(), cast(birth_date AS date)),'####'))) as col2 \n"
+
+        "FROM cp.`employee.json`";
+
+    testBuilder()
+        .sqlQuery(query)
+        .ordered()
+        .baselineColumns("col1", "col2")
+        .baselineValues(1155l, 1155l)
+        .build()
+        .run();
+  }
 }


Mime
View raw message