amaliujia commented on a change in pull request #1587: [CALCITE-3272] Support 
TUMBLE as Table Valued Function including an enumerable implementation, 
stream.iq and DESCRIPTOR
URL: https://github.com/apache/calcite/pull/1587#discussion_r358634550
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java
 ##########
 @@ -510,6 +510,52 @@ public boolean checkOperandTypes(
   public static final SqlSingleOperandTypeChecker NUMERIC_OR_STRING =
       OperandTypes.or(NUMERIC, STRING);
 
+  /**
+   * Used when a table function's parameter is a TABLE parameter, which has 
type
+   * as ROW.
+   */
+  public static final SqlSingleOperandTypeChecker ROW =
+      new SqlSingleOperandTypeChecker() {
+        public boolean checkSingleOperandType(
+            SqlCallBinding callBinding,
+            SqlNode node,
+            int iFormalOperand,
+            boolean throwOnFailure) {
+          assert 0 == iFormalOperand;
+          RelDataType type =
+              callBinding.getValidator().deriveType(
+                  callBinding.getScope(),
+                  node);
+          return type.getSqlTypeName() == SqlTypeName.ROW;
+        }
+
+        public boolean checkOperandTypes(
+            SqlCallBinding callBinding,
+            boolean throwOnFailure) {
+          return checkSingleOperandType(
+              callBinding,
+              callBinding.operand(0),
+              0,
+              throwOnFailure);
+        }
+
+        public SqlOperandCountRange getOperandCountRange() {
+          return SqlOperandCountRanges.of(3);
+        }
 
 Review comment:
   Now I finally understand how a right `OperandTypeChecker` should be written. 
I have updated this `ROW` to `TABLE_VALUED_FUNCTION_TUMBLE_CHECKER` and add 
more comments. Now this checker checks TUMBLE only with 3 operand, whose types 
are `ROW`, `COLUMN_LIST`, `DATETIME_INTERVAL` separately.  Please take a look.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to