Class SqlCall
- java.lang.Object
-
- org.apache.calcite.sql.SqlNode
-
- org.apache.calcite.sql.SqlCall
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
SqlAlter
,SqlAttributeDefinition
,SqlBasicCall
,SqlCase
,SqlCheckConstraint
,SqlColumnDeclaration
,SqlDdl
,SqlDelete
,SqlDescribeSchema
,SqlDescribeTable
,SqlExplain
,SqlInsert
,SqlJoin
,SqlKeyConstraint
,SqlMatchRecognize
,SqlMerge
,SqlOrderBy
,SqlSelect
,SqlUpdate
,SqlWindow
,SqlWith
,SqlWithItem
public abstract class SqlCall extends SqlNode
ASqlCall
is a call to anoperator
. (Operators can be used to describe any syntactic construct, so in practice, every non-leaf node in a SQL parse tree is aSqlCall
of some kind.)
-
-
Field Summary
-
Fields inherited from class org.apache.calcite.sql.SqlNode
EMPTY_ARRAY, pos
-
-
Constructor Summary
Constructors Constructor Description SqlCall(SqlParserPos pos)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <R> R
accept(SqlVisitor<R> visitor)
Accepts a generic visitor.SqlNode
clone(SqlParserPos pos)
Clones a SqlNode with a different position.boolean
equalsDeep(SqlNode node, Litmus litmus)
Returns whether this node is structurally equivalent to another node.void
findValidOptions(SqlValidator validator, SqlValidatorScope scope, SqlParserPos pos, java.util.Collection<SqlMoniker> hintList)
Lists all the valid alternatives for this node if the parse position of the node matches that of pos.protected java.lang.String
getCallSignature(SqlValidator validator, SqlValidatorScope scope)
Returns a string describing the actual argument types of a call, e.g.SqlLiteral
getFunctionQuantifier()
SqlKind
getKind()
Returns the type of node this is, orSqlKind.OTHER
if it's nothing special.SqlMonotonicity
getMonotonicity(SqlValidatorScope scope)
Returns whether expression is always ascending, descending or constant.abstract java.util.List<SqlNode>
getOperandList()
abstract SqlOperator
getOperator()
boolean
isCountStar()
Test to see if it is the function COUNT(*)boolean
isExpanded()
Whether this call was created by expanding a parentheses-free call to what was syntactically an identifier.<S extends SqlNode>
Soperand(int i)
int
operandCount()
void
setOperand(int i, SqlNode operand)
Changes the value of an operand.void
unparse(SqlWriter writer, int leftPrec, int rightPrec)
Writes a SQL representation of this node to a writer.void
validate(SqlValidator validator, SqlValidatorScope scope)
Validates this call.-
Methods inherited from class org.apache.calcite.sql.SqlNode
clone, clone, cloneArray, equalDeep, equalDeep, equalsDeep, getParserPosition, isA, toSqlString, toSqlString, toString, validateExpr
-
-
-
-
Constructor Detail
-
SqlCall
public SqlCall(SqlParserPos pos)
-
-
Method Detail
-
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, SqlNode operand)
Changes the value of an operand. Allows some rewrite bySqlValidator
; use sparingly.- Parameters:
i
- Operand indexoperand
- Operand value
-
getKind
public SqlKind getKind()
Description copied from class:SqlNode
Returns the type of node this is, orSqlKind.OTHER
if it's nothing special.- Overrides:
getKind
in classSqlNode
- Returns:
- a
SqlKind
value, never null - See Also:
SqlNode.isA(java.util.Set<org.apache.calcite.sql.SqlKind>)
-
getOperator
public abstract SqlOperator getOperator()
-
getOperandList
public abstract java.util.List<SqlNode> getOperandList()
-
operand
public <S extends SqlNode> S operand(int i)
-
operandCount
public int operandCount()
-
clone
public SqlNode clone(SqlParserPos pos)
Description copied from class:SqlNode
Clones a SqlNode with a different position.
-
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
andrightPrec
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)
.
-
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 exampleSqlSelect
andSqlUpdate
).
-
findValidOptions
public void findValidOptions(SqlValidator validator, SqlValidatorScope scope, SqlParserPos pos, java.util.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.- Overrides:
findValidOptions
in classSqlNode
- Parameters:
validator
- Validatorscope
- Validation scopepos
- SqlParserPos indicating the cursor position at which completion hints are requested forhintList
- 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 thevisitor object
.The type parameter
R
must be consistent with the type parameter of the visitor.
-
equalsDeep
public boolean equalsDeep(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 classSqlNode
-
getCallSignature
protected java.lang.String getCallSignature(SqlValidator validator, 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
.- Overrides:
getMonotonicity
in classSqlNode
- Parameters:
scope
- Scope
-
isCountStar
public boolean isCountStar()
Test to see if it is the function COUNT(*)- Returns:
- boolean true if function call to COUNT(*)
-
getFunctionQuantifier
public SqlLiteral getFunctionQuantifier()
-
-