calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [6/7] incubator-calcite git commit: [CALCITE-672] SQL ANY type should be nullable (Jinfeng Ni)
Date Tue, 07 Apr 2015 20:36:17 GMT
[CALCITE-672] SQL ANY type should be nullable (Jinfeng Ni)

Close apache/incubator-calcite#76


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

Branch: refs/heads/r1.2
Commit: a00e45219ab32455b431a4497ba3bd034ff460ea
Parents: 66b62c5
Author: Jinfeng Ni <jni@maprtech.com>
Authored: Tue Apr 7 11:30:59 2015 -0700
Committer: Julian Hyde <jhyde@apache.org>
Committed: Tue Apr 7 13:17:03 2015 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java | 6 ++++--
 .../java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java     | 6 +++---
 .../java/org/apache/calcite/prepare/CalciteCatalogReader.java | 3 ++-
 .../java/org/apache/calcite/sql/SqlUnresolvedFunction.java    | 5 ++++-
 .../java/org/apache/calcite/sql/fun/SqlCountAggFunction.java  | 4 +++-
 .../apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java  | 7 +++++--
 .../apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java  | 7 +++++--
 .../main/java/org/apache/calcite/adapter/csv/JsonTable.java   | 3 ++-
 .../java/org/apache/calcite/adapter/mongodb/MongoTable.java   | 3 ++-
 9 files changed, 30 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
index de97237..cce3fcc 100644
--- a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
+++ b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
@@ -293,7 +293,8 @@ public class JdbcSchema implements Schema {
         component = parseTypeString(typeFactory, remaining);
       }
       if (component == null) {
-        component = typeFactory.createSqlType(SqlTypeName.ANY);
+        component = typeFactory.createTypeWithNullability(
+            typeFactory.createSqlType(SqlTypeName.ANY), true);
       }
       return typeFactory.createArrayType(component, -1);
     }
@@ -339,7 +340,8 @@ public class JdbcSchema implements Schema {
           ? typeFactory.createSqlType(typeName, precision)
           : typeFactory.createSqlType(typeName);
     } catch (IllegalArgumentException e) {
-      return typeFactory.createSqlType(SqlTypeName.ANY);
+      return typeFactory.createTypeWithNullability(
+          typeFactory.createSqlType(SqlTypeName.ANY), true);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java b/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
index 0ef9128..b413676 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
@@ -111,11 +111,11 @@ public class JavaTypeFactoryImpl
           createType(clazz.getComponentType()), -1);
     } else if (List.class.isAssignableFrom(clazz)) {
       return createArrayType(
-          createSqlType(SqlTypeName.ANY), -1);
+          createTypeWithNullability(createSqlType(SqlTypeName.ANY), true), -1);
     } else if (Map.class.isAssignableFrom(clazz)) {
       return createMapType(
-          createSqlType(SqlTypeName.ANY),
-          createSqlType(SqlTypeName.ANY));
+          createTypeWithNullability(createSqlType(SqlTypeName.ANY), true),
+          createTypeWithNullability(createSqlType(SqlTypeName.ANY), true));
     } else {
       return createStructType(clazz);
     }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java b/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java
index 263db18..ada3442 100644
--- a/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java
+++ b/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java
@@ -287,7 +287,8 @@ public class CalciteCatalogReader implements Prepare.CatalogReader,
             if (input instanceof RelDataTypeFactoryImpl.JavaType
                 && ((RelDataTypeFactoryImpl.JavaType) input).getJavaClass()
                 == Object.class) {
-              return typeFactory.createSqlType(SqlTypeName.ANY);
+              return typeFactory.createTypeWithNullability(
+                  typeFactory.createSqlType(SqlTypeName.ANY), true);
             }
             return typeFactory.toSql(input);
           }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/core/src/main/java/org/apache/calcite/sql/SqlUnresolvedFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlUnresolvedFunction.java b/core/src/main/java/org/apache/calcite/sql/SqlUnresolvedFunction.java
index d41b4e3..b2e2e9f 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlUnresolvedFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlUnresolvedFunction.java
@@ -17,6 +17,7 @@
 package org.apache.calcite.sql;
 
 import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.sql.type.SqlOperandTypeChecker;
 import org.apache.calcite.sql.type.SqlOperandTypeInference;
 import org.apache.calcite.sql.type.SqlReturnTypeInference;
@@ -63,7 +64,9 @@ public class SqlUnresolvedFunction extends SqlFunction {
    * fail.
    */
   @Override public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
-    return opBinding.getTypeFactory().createSqlType(SqlTypeName.ANY);
+    final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
+    return typeFactory.createTypeWithNullability(
+        typeFactory.createSqlType(SqlTypeName.ANY), true);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java
index 0d9e1a5..a08a96e 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java
@@ -62,7 +62,9 @@ public class SqlCountAggFunction extends SqlAggFunction {
   }
 
   public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
-    return ImmutableList.of(typeFactory.createSqlType(SqlTypeName.ANY));
+    return ImmutableList.of(
+        typeFactory.createTypeWithNullability(
+            typeFactory.createSqlType(SqlTypeName.ANY), true));
   }
 
   public RelDataType getReturnType(RelDataTypeFactory typeFactory) {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
b/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
index 5d382c3..2ca5375 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
@@ -57,11 +57,14 @@ public class SqlFirstLastValueAggFunction extends SqlAggFunction {
   }
 
   public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
-    return ImmutableList.of(typeFactory.createSqlType(SqlTypeName.ANY));
+    return ImmutableList.of(
+        typeFactory.createTypeWithNullability(
+            typeFactory.createSqlType(SqlTypeName.ANY), true));
   }
 
   public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
-    return typeFactory.createSqlType(SqlTypeName.ANY);
+    return typeFactory.createTypeWithNullability(
+        typeFactory.createSqlType(SqlTypeName.ANY), true);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
b/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
index b1d50b8..50fa487 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
@@ -50,11 +50,14 @@ public class SqlSumEmptyIsZeroAggFunction extends SqlAggFunction {
   //~ Methods ----------------------------------------------------------------
 
   public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
-    return ImmutableList.of(typeFactory.createSqlType(SqlTypeName.ANY));
+    return ImmutableList.of(
+        typeFactory.createTypeWithNullability(
+            typeFactory.createSqlType(SqlTypeName.ANY), true));
   }
 
   public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
-    return typeFactory.createSqlType(SqlTypeName.ANY);
+    return typeFactory.createTypeWithNullability(
+        typeFactory.createSqlType(SqlTypeName.ANY), true);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/example/csv/src/main/java/org/apache/calcite/adapter/csv/JsonTable.java
----------------------------------------------------------------------
diff --git a/example/csv/src/main/java/org/apache/calcite/adapter/csv/JsonTable.java b/example/csv/src/main/java/org/apache/calcite/adapter/csv/JsonTable.java
index 95b0247..22ea30c 100644
--- a/example/csv/src/main/java/org/apache/calcite/adapter/csv/JsonTable.java
+++ b/example/csv/src/main/java/org/apache/calcite/adapter/csv/JsonTable.java
@@ -47,7 +47,8 @@ public class JsonTable extends AbstractTable implements ScannableTable {
     return typeFactory.builder().add("_MAP",
         typeFactory.createMapType(
             typeFactory.createSqlType(SqlTypeName.VARCHAR),
-            typeFactory.createSqlType(SqlTypeName.ANY))).build();
+            typeFactory.createTypeWithNullability(
+                typeFactory.createSqlType(SqlTypeName.ANY), true))).build();
   }
 
   public Enumerable<Object[]> scan(DataContext root) {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a00e4521/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java
index edb5e37..2c362a3 100644
--- a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java
+++ b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoTable.java
@@ -69,7 +69,8 @@ public class MongoTable extends AbstractQueryableTable
     final RelDataType mapType =
         typeFactory.createMapType(
             typeFactory.createSqlType(SqlTypeName.VARCHAR),
-            typeFactory.createSqlType(SqlTypeName.ANY));
+            typeFactory.createTypeWithNullability(
+                typeFactory.createSqlType(SqlTypeName.ANY), true));
     return typeFactory.builder().add("_MAP", mapType).build();
   }
 


Mime
View raw message