[CALCITE-1442] Interval fractional second precision returns wrong value 
(Laurent Goujon)

SqlIntervalQualifier.getFractionalSecondPrecisionPreservingDefault()
was returning the wrong field.

Close apache/calcite#309


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

Branch: refs/heads/master
Commit: 25a7d938de915ebaa6d64ebe64b2e5618b3becca
Parents: 55ba6b5
Author: Laurent Goujon <laur...@dremio.com>
Authored: Fri Oct 14 15:58:41 2016 -0700
Committer: Julian Hyde <jh...@apache.org>
Committed: Mon Oct 17 15:06:37 2016 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/calcite/sql/SqlIntervalQualifier.java    | 2 +-
 core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java  | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/25a7d938/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java 
b/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java
index 9be154c..b27c5b8 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlIntervalQualifier.java
@@ -248,7 +248,7 @@ public class SqlIntervalQualifier extends SqlNode {
     if (useDefaultFractionalSecondPrecision()) {
       return RelDataType.PRECISION_NOT_SPECIFIED;
     } else {
-      return startPrecision;
+      return fractionalSecondPrecision;
     }
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/25a7d938/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
index fc3010b..a6d0c35 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -527,6 +527,9 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
     checkExpType(
         "CASE 1 WHEN 1 THEN cast(null as integer) WHEN 2 THEN cast(cast(null 
as tinyint) as integer) END",
         "INTEGER");
+    checkExpType(
+        "CASE 1 WHEN 1 THEN INTERVAL '12 3:4:5.6' DAY TO SECOND(6) WHEN 2 THEN 
INTERVAL '12 3:4:5.6' DAY TO SECOND(9) END",
+        "INTERVAL DAY TO SECOND(9)");
   }
 
   @Test public void testCaseExpressionFails() {

Reply via email to