Class SqlGroupedWindowFunction

java.lang.Object
org.apache.calcite.sql.SqlOperator
org.apache.calcite.sql.SqlFunction
org.apache.calcite.sql.SqlGroupedWindowFunction

public class SqlGroupedWindowFunction extends org.apache.calcite.sql.SqlFunction
SQL function that computes keys by which rows can be partitioned and aggregated.

Grouped window functions always occur in the GROUP BY clause. They often have auxiliary functions that access information about the group. For example, HOP is a group function, and its auxiliary functions are HOP_START and HOP_END. Here they are used in a streaming query:

Note: we copied the implementation from Calcite's SqlGroupedWindowFunction because of CALCITE-4563, Calcite currently doesn't allow to set the SqlReturnTypeInference of auxiliary SqlGroupedWindowFunction.

The motivation is using TIMESTAMP type for the window start and window end no matter the time attribute column is TIMESTAMP or TIMESTAMP_LTZ.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The grouped function, if this an auxiliary function; null otherwise.

    Fields inherited from class org.apache.calcite.sql.SqlOperator

    kind, MDX_PRECEDENCE, NL
  • Constructor Summary

    Constructors
    Constructor
    Description
    SqlGroupedWindowFunction(String name, org.apache.calcite.sql.SqlKind kind, SqlGroupedWindowFunction groupFunction, org.apache.calcite.sql.type.SqlOperandTypeChecker operandTypeChecker)
    Creates a SqlGroupedWindowFunction.
    SqlGroupedWindowFunction(String name, org.apache.calcite.sql.SqlKind kind, SqlGroupedWindowFunction groupFunction, org.apache.calcite.sql.type.SqlReturnTypeInference returnTypeInference, org.apache.calcite.sql.type.SqlOperandTypeInference operandTypeInference, org.apache.calcite.sql.type.SqlOperandTypeChecker operandTypeChecker, org.apache.calcite.sql.SqlFunctionCategory category)
    Creates a SqlGroupedWindowFunction.
  • Method Summary

    Modifier and Type
    Method
    Description
    auxiliary(String name, org.apache.calcite.sql.SqlKind kind)
    Creates an auxiliary function from this grouped window function.
    auxiliary(org.apache.calcite.sql.SqlKind kind)
    Creates an auxiliary function from this grouped window function.
    Returns a list of this grouped window function's auxiliary functions.
    org.apache.calcite.sql.validate.SqlMonotonicity
    getMonotonicity(org.apache.calcite.sql.SqlOperatorBinding call)
     
    boolean
     
    boolean
     

    Methods inherited from class org.apache.calcite.sql.SqlFunction

    deriveType, getFunctionType, getNameAsId, getParamNames, getParamTypes, getSqlIdentifier, getSyntax, isQuantifierAllowed, unparse, validateCall, validateQuantifier

    Methods inherited from class org.apache.calcite.sql.SqlOperator

    acceptCall, acceptCall, adjustType, allowsFraming, argumentMustBeScalar, checkOperandCount, checkOperandTypes, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, createCall, createCall, createCall, createCall, deriveOperandType, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getName, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, getStrongPolicyInference, hashCode, inferReturnType, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isName, isSymmetrical, leftPrec, not, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, reverse, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands, validRexOperands

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • groupFunction

      public final SqlGroupedWindowFunction groupFunction
      The grouped function, if this an auxiliary function; null otherwise.
  • Constructor Details

    • SqlGroupedWindowFunction

      public SqlGroupedWindowFunction(String name, org.apache.calcite.sql.SqlKind kind, SqlGroupedWindowFunction groupFunction, org.apache.calcite.sql.type.SqlReturnTypeInference returnTypeInference, org.apache.calcite.sql.type.SqlOperandTypeInference operandTypeInference, org.apache.calcite.sql.type.SqlOperandTypeChecker operandTypeChecker, org.apache.calcite.sql.SqlFunctionCategory category)
      Creates a SqlGroupedWindowFunction.
      Parameters:
      name - Function name
      kind - Kind
      groupFunction - Group function, if this is an auxiliary; null, if this is a group function
      returnTypeInference - Strategy to use for return type inference
      operandTypeInference - Strategy to use for parameter type inference
      operandTypeChecker - Strategy to use for parameter type checking
      category - Categorization for function
    • SqlGroupedWindowFunction

      public SqlGroupedWindowFunction(String name, org.apache.calcite.sql.SqlKind kind, SqlGroupedWindowFunction groupFunction, org.apache.calcite.sql.type.SqlOperandTypeChecker operandTypeChecker)
      Creates a SqlGroupedWindowFunction.
      Parameters:
      name - Function name
      kind - Kind
      groupFunction - Group function, if this is an auxiliary; null, if this is a group function
  • Method Details

    • auxiliary

      public SqlGroupedWindowFunction auxiliary(org.apache.calcite.sql.SqlKind kind)
      Creates an auxiliary function from this grouped window function.
      Parameters:
      kind - Kind; also determines function name
    • auxiliary

      public SqlGroupedWindowFunction auxiliary(String name, org.apache.calcite.sql.SqlKind kind)
      Creates an auxiliary function from this grouped window function.
      Parameters:
      name - Function name
      kind - Kind
    • getAuxiliaryFunctions

      public List<SqlGroupedWindowFunction> getAuxiliaryFunctions()
      Returns a list of this grouped window function's auxiliary functions.
    • isGroup

      public boolean isGroup()
      Overrides:
      isGroup in class org.apache.calcite.sql.SqlOperator
    • isGroupAuxiliary

      public boolean isGroupAuxiliary()
      Overrides:
      isGroupAuxiliary in class org.apache.calcite.sql.SqlOperator
    • getMonotonicity

      public org.apache.calcite.sql.validate.SqlMonotonicity getMonotonicity(org.apache.calcite.sql.SqlOperatorBinding call)
      Overrides:
      getMonotonicity in class org.apache.calcite.sql.SqlOperator