Class SqlCall

All Implemented Interfaces:
Direct Known Subclasses:
SqlAlter, SqlAttributeDefinition, SqlBasicCall, SqlBegin, SqlCase, SqlCheckConstraint, SqlColumnDeclaration, SqlCommit, SqlDdl, SqlDelete, SqlDescribeSchema, SqlDescribeTable, SqlDiscard, SqlExplain, SqlHint, SqlInsert, SqlJoin, SqlKeyConstraint, SqlLambda, SqlMatchRecognize, SqlMerge, SqlOrderBy, SqlPivot, SqlRollback, SqlSelect, SqlShow, SqlSnapshot, SqlTableRef, SqlUnpivot, SqlUpdate, SqlWindow, SqlWith, SqlWithItem

public abstract class SqlCall extends SqlNode
A SqlCall is a call to an operator. (Operators can be used to describe any syntactic construct, so in practice, every non-leaf node in a SQL parse tree is a SqlCall of some kind.)
  • Constructor Details

  • Method Details

    • isExpanded

      public boolean isExpanded()
      Whether this call was created by expanding a parentheses-free call to what was syntactically an identifier.
    • setOperand

      public void setOperand(int i, @Nullable SqlNode operand)
      Changes the value of an operand. Allows some rewrite by SqlValidator; use sparingly.
      i - Operand index
      operand - Operand value
    • getKind

      public SqlKind getKind()
      Description copied from class: SqlNode
      Returns the type of node this is, or SqlKind.OTHER if it's nothing special.
      getKind in class SqlNode
      a SqlKind value, never null
      See Also:
    • getOperator

      @Pure public abstract SqlOperator getOperator()
    • getOperandList

      public abstract List<SqlNode> getOperandList()
      Returns the list of operands. The set and order of operands is call-specific.

      Note: the proper type would be List<@Nullable SqlNode>, however, it would trigger too many changes to the current codebase.

      the list of call operands, never null, the operands can be null
    • operand

      public <S extends SqlNode> S operand(int i)
      Returns i-th operand (0-based).

      Note: the result might be null, so the proper signature would be <S extends @Nullable SqlNode>, however, it would trigger to many changes to the current codebase.

      Type Parameters:
      S - type of the result
      i - operand index (0-based)
      i-th operand (0-based), the result might be null
    • operandCount

      public int operandCount()
    • clone

      public SqlNode clone(SqlParserPos pos)
      Description copied from class: SqlNode
      Clones a SqlNode with a different position.
      Specified by:
      clone in class SqlNode
    • unparse

      public void unparse(SqlWriter writer, int leftPrec, int rightPrec)
      Description copied from class: SqlNode
      Writes a SQL representation of this node to a writer.

      The leftPrec and rightPrec parameters give us enough context to decide whether we need to enclose the expression in parentheses. For example, we need parentheses around "2 + 3" if preceded by "5 *". This is because the precedence of the "*" operator is greater than the precedence of the "+" operator.

      The algorithm handles left- and right-associative operators by giving them slightly different left- and right-precedence.

      If SqlWriter.isAlwaysUseParentheses() is true, we use parentheses even when they are not required by the precedence rules.

      For the details of this algorithm, see unparse(org.apache.calcite.sql.SqlWriter, int, int).

      Specified by:
      unparse in class SqlNode
      writer - Target writer
      leftPrec - The precedence of the SqlNode immediately preceding this node in a depth-first scan of the parse tree
      rightPrec - The precedence of the SqlNode immediately
    • validate

      public void validate(SqlValidator validator, SqlValidatorScope scope)
      Validates this call.

      The default implementation delegates the validation to the operator's SqlOperator.validateCall(org.apache.calcite.sql.SqlCall, org.apache.calcite.sql.validate.SqlValidator, org.apache.calcite.sql.validate.SqlValidatorScope, org.apache.calcite.sql.validate.SqlValidatorScope). Derived classes may override (as do, for example SqlSelect and SqlUpdate).

      Specified by:
      validate in class SqlNode
      scope - Validator
    • findValidOptions

      public void findValidOptions(SqlValidator validator, SqlValidatorScope scope, SqlParserPos pos, Collection<SqlMoniker> hintList)
      Description copied from class: SqlNode
      Lists all the valid alternatives for this node if the parse position of the node matches that of pos. Only implemented now for SqlCall and SqlOperator.
      findValidOptions in class SqlNode
      validator - Validator
      scope - Validation scope
      pos - SqlParserPos indicating the cursor position at which completion hints are requested for
      hintList - list of valid options
    • accept

      public <R> R accept(SqlVisitor<R> visitor)
      Description copied from class: SqlNode
      Accepts a generic visitor.

      Implementations of this method in subtypes simply call the appropriate visit method on the visitor object.

      The type parameter R must be consistent with the type parameter of the visitor.

      Specified by:
      accept in class SqlNode
    • equalsDeep

      public boolean equalsDeep(@Nullable SqlNode node, Litmus litmus)
      Description copied from class: SqlNode
      Returns whether this node is structurally equivalent to another node. Some examples:
      • 1 + 2 is structurally equivalent to 1 + 2
      • 1 + 2 + 3 is structurally equivalent to (1 + 2) + 3, but not to 1 + (2 + 3), because the '+' operator is left-associative
      Specified by:
      equalsDeep in class SqlNode
    • getCallSignature

      public String getCallSignature(SqlValidator validator, @Nullable SqlValidatorScope scope)
      Returns a string describing the actual argument types of a call, e.g. "SUBSTR(VARCHAR(12), NUMBER(3,2), INTEGER)".
    • getMonotonicity

      public SqlMonotonicity getMonotonicity(SqlValidatorScope scope)
      Description copied from class: SqlNode
      Returns whether expression is always ascending, descending or constant. This property is useful because it allows to safely aggregate infinite streams of values.

      The default implementation returns SqlMonotonicity.NOT_MONOTONIC.

      getMonotonicity in class SqlNode
      scope - Scope
    • isCountStar

      public boolean isCountStar()
      Returns whether it is the function COUNT(*).
      true if function call to COUNT(*)
    • getFunctionQuantifier

      @Pure public @Nullable SqlLiteral getFunctionQuantifier()