calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [2/3] incubator-calcite git commit: Fix QUARTER function for null values and JDBC escape syntax
Date Thu, 11 Dec 2014 07:56:24 GMT
Fix QUARTER function for null values and JDBC escape syntax


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

Branch: refs/heads/master
Commit: 0ab7f5ef0f67c8bb96d4460d733ad4e953643085
Parents: a059f76
Author: Julian Hyde <jhyde@apache.org>
Authored: Wed Dec 10 17:56:45 2014 -0800
Committer: Julian Hyde <jhyde@apache.org>
Committed: Wed Dec 10 18:02:47 2014 -0800

----------------------------------------------------------------------
 .../java/org/apache/calcite/sql/SqlJdbcFunctionCall.java     | 3 +++
 .../org/apache/calcite/sql2rel/StandardConvertletTable.java  | 7 +++++--
 .../org/apache/calcite/sql/test/SqlOperatorBaseTest.java     | 8 ++++----
 3 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/0ab7f5ef/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java b/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
index 91a8acf..63ffb8d 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
@@ -723,6 +723,9 @@ public class SqlJdbcFunctionCall extends SqlFunction {
             }
           });
       map.put(
+          "QUARTER",
+          new MakeCall(SqlStdOperatorTable.QUARTER, 1));
+      map.put(
           "RTRIM",
           new MakeCall(SqlStdOperatorTable.TRIM, 1) {
             @Override SqlCall createCall(

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/0ab7f5ef/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
index 9c85772..7ecfd37 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
@@ -564,8 +564,11 @@ public class StandardConvertletTable extends ReflectiveConvertletTable
{
     assert operands.size() == 1;
     RexNode x = cx.convertExpression(operands.get(0));
     final RexBuilder rexBuilder = cx.getRexBuilder();
-    RelDataType resType =
-        cx.getTypeFactory().createSqlType(SqlTypeName.BIGINT);
+    final RelDataTypeFactory typeFactory = cx.getTypeFactory();
+    final RelDataType resType =
+        typeFactory.createTypeWithNullability(
+            typeFactory.createSqlType(SqlTypeName.BIGINT),
+            x.getType().isNullable());
     RexNode res =
         rexBuilder.makeCall(
             resType,

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/0ab7f5ef/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
index d5d6d00..9e08be8 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
@@ -1478,7 +1478,7 @@ public abstract class SqlOperatorBaseTest {
 
     // Numeric Functions
     if (!enable) {
-      return;
+//      return;
     }
     tester.checkScalar("{fn ABS(-3)}", 3, "INTEGER NOT NULL");
     if (false) {
@@ -1666,9 +1666,8 @@ public abstract class SqlOperatorBaseTest {
       tester.checkScalar("{fn MONTHNAME(date)}", null, "");
     }
     tester.checkType("{fn NOW()}", "TIMESTAMP(0) NOT NULL");
-    if (false) {
-      tester.checkScalar("{fn QUARTER(date)}", null, "");
-    }
+    tester.checkScalar("{fn QUARTER(DATE '2014-12-10')}", "4",
+        "BIGINT NOT NULL");
     if (false) {
       tester.checkScalar("{fn SECOND(time)}", null, "");
     }
@@ -4140,6 +4139,7 @@ public abstract class SqlOperatorBaseTest {
         "quarter(date '2008-12-23')",
         "4",
         "BIGINT NOT NULL");
+    tester.checkNull("quarter(cast(null as date))");
   }
 
   @Test public void testExtractFunc() {


Mime
View raw message