calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [4/4] calcite git commit: [CALCITE-2133] In SqlGroupedWindowFunction constructor, add returnTypeInference, operandTypeInference and category parameters (Shuyi Chen)
Date Thu, 18 Jan 2018 01:35:46 GMT
[CALCITE-2133] In SqlGroupedWindowFunction constructor, add returnTypeInference, operandTypeInference
and category parameters (Shuyi Chen)

Deprecate the previous constructors.

Close apache/calcite#606


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

Branch: refs/heads/master
Commit: 522f65487e0ad632c339590b0ee6bd91a4890bda
Parents: 7f86f4e
Author: Shuyi Chen <shuyi@uber.com>
Authored: Fri Jan 12 18:41:00 2018 -0800
Committer: Julian Hyde <jhyde@apache.org>
Committed: Wed Jan 17 17:34:55 2018 -0800

----------------------------------------------------------------------
 .../calcite/sql/SqlGroupedWindowFunction.java   | 43 ++++++++++++--------
 .../calcite/sql/fun/SqlStdOperatorTable.java    | 18 +++++---
 2 files changed, 39 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/522f6548/core/src/main/java/org/apache/calcite/sql/SqlGroupedWindowFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlGroupedWindowFunction.java b/core/src/main/java/org/apache/calcite/sql/SqlGroupedWindowFunction.java
index ef982fa..59d4242 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlGroupedWindowFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlGroupedWindowFunction.java
@@ -18,8 +18,11 @@ package org.apache.calcite.sql;
 
 import org.apache.calcite.sql.type.ReturnTypes;
 import org.apache.calcite.sql.type.SqlOperandTypeChecker;
+import org.apache.calcite.sql.type.SqlOperandTypeInference;
+import org.apache.calcite.sql.type.SqlReturnTypeInference;
 import org.apache.calcite.sql.validate.SqlMonotonicity;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
@@ -52,30 +55,37 @@ public class SqlGroupedWindowFunction extends SqlFunction {
    * @param kind Kind
    * @param groupFunction Group function, if this is an auxiliary;
    *                      null, if this is a group function
-   * @param operandTypeChecker Operand type checker
+   * @param returnTypeInference  Strategy to use for return type inference
+   * @param operandTypeInference Strategy to use for parameter type inference
+   * @param operandTypeChecker   Strategy to use for parameter type checking
+   * @param category             Categorization for function
    */
   public SqlGroupedWindowFunction(String name, SqlKind kind,
       SqlGroupedWindowFunction groupFunction,
-      SqlOperandTypeChecker operandTypeChecker) {
-    super(name, kind, ReturnTypes.ARG0, null,
-        operandTypeChecker, SqlFunctionCategory.SYSTEM);
+      SqlReturnTypeInference returnTypeInference,
+      SqlOperandTypeInference operandTypeInference,
+      SqlOperandTypeChecker operandTypeChecker, SqlFunctionCategory category) {
+    super(name, kind, returnTypeInference, operandTypeInference,
+        operandTypeChecker, category);
     this.groupFunction = groupFunction;
-    if (groupFunction != null) {
-      assert groupFunction.groupFunction == null;
-    }
+    Preconditions.checkArgument(groupFunction == null
+        || groupFunction.groupFunction == null);
   }
 
-  /** Creates a SqlGroupedWindowFunction.
-   *
-   * @param kind Kind; also determines function name
-   * @param groupFunction Group function, if this is an auxiliary;
-   *                      null, if this is a group function
-   * @param operandTypeChecker Operand type checker
-   */
+  @Deprecated // to be removed before 2.0
+  public SqlGroupedWindowFunction(String name, SqlKind kind,
+      SqlGroupedWindowFunction groupFunction,
+      SqlOperandTypeChecker operandTypeChecker) {
+    this(name, kind, groupFunction, ReturnTypes.ARG0, null, operandTypeChecker,
+        SqlFunctionCategory.SYSTEM);
+  }
+
+  @Deprecated // to be removed before 2.0
   public SqlGroupedWindowFunction(SqlKind kind,
       SqlGroupedWindowFunction groupFunction,
       SqlOperandTypeChecker operandTypeChecker) {
-    this(kind.name(), kind, groupFunction, operandTypeChecker);
+    this(kind.name(), kind, groupFunction, ReturnTypes.ARG0, null,
+        operandTypeChecker, SqlFunctionCategory.SYSTEM);
   }
 
   /** Creates an auxiliary function from this grouped window function.
@@ -92,7 +102,8 @@ public class SqlGroupedWindowFunction extends SqlFunction {
    * @param kind Kind
    */
   public SqlGroupedWindowFunction auxiliary(String name, SqlKind kind) {
-    return new SqlGroupedWindowFunction(name, kind, this, getOperandTypeChecker());
+    return new SqlGroupedWindowFunction(name, kind, this, ReturnTypes.ARG0,
+        null, getOperandTypeChecker(), SqlFunctionCategory.SYSTEM);
   }
 
   /** Returns a list of this grouped window function's auxiliary functions. */

http://git-wip-us.apache.org/repos/asf/calcite/blob/522f6548/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
index c56b8bc..cfff50f 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
@@ -2006,9 +2006,11 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable
{
 
   /** The {@code TUMBLE} group function. */
   public static final SqlGroupedWindowFunction TUMBLE =
-      new SqlGroupedWindowFunction(SqlKind.TUMBLE, null,
+      new SqlGroupedWindowFunction(SqlKind.TUMBLE.name(), SqlKind.TUMBLE,
+          null, ReturnTypes.ARG0, null,
           OperandTypes.or(OperandTypes.DATETIME_INTERVAL,
-              OperandTypes.DATETIME_INTERVAL_TIME)) {
+              OperandTypes.DATETIME_INTERVAL_TIME),
+          SqlFunctionCategory.SYSTEM) {
         @Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
           return ImmutableList.of(TUMBLE_START, TUMBLE_END);
         }
@@ -2026,9 +2028,11 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable
{
 
   /** The {@code HOP} group function. */
   public static final SqlGroupedWindowFunction HOP =
-      new SqlGroupedWindowFunction(SqlKind.HOP, null,
+      new SqlGroupedWindowFunction(SqlKind.HOP.name(), SqlKind.HOP, null,
+          ReturnTypes.ARG0, null,
           OperandTypes.or(OperandTypes.DATETIME_INTERVAL_INTERVAL,
-              OperandTypes.DATETIME_INTERVAL_INTERVAL_TIME)) {
+              OperandTypes.DATETIME_INTERVAL_INTERVAL_TIME),
+          SqlFunctionCategory.SYSTEM) {
         @Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
           return ImmutableList.of(HOP_START, HOP_END);
         }
@@ -2046,9 +2050,11 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable
{
 
   /** The {@code SESSION} group function. */
   public static final SqlGroupedWindowFunction SESSION =
-      new SqlGroupedWindowFunction(SqlKind.SESSION, null,
+      new SqlGroupedWindowFunction(SqlKind.SESSION.name(), SqlKind.SESSION,
+          null, ReturnTypes.ARG0, null,
           OperandTypes.or(OperandTypes.DATETIME_INTERVAL,
-              OperandTypes.DATETIME_INTERVAL_TIME)) {
+              OperandTypes.DATETIME_INTERVAL_TIME),
+          SqlFunctionCategory.SYSTEM) {
         @Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
           return ImmutableList.of(SESSION_START, SESSION_END);
         }


Mime
View raw message