Class SqlDotOperator
- java.lang.Object
-
- org.apache.calcite.sql.SqlOperator
-
- org.apache.calcite.sql.SqlSpecialOperator
-
- org.apache.calcite.sql.fun.SqlDotOperator
-
public class SqlDotOperator extends SqlSpecialOperator
The dot operator.
, used to access a field of a record. For example,a.b
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.calcite.sql.SqlSpecialOperator
SqlSpecialOperator.ReduceResult, SqlSpecialOperator.TokenSequence
-
-
Field Summary
-
Fields inherited from class org.apache.calcite.sql.SqlOperator
kind, MDX_PRECEDENCE, NL
-
-
Constructor Summary
Constructors Constructor Description SqlDotOperator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> void
acceptCall(SqlVisitor<R> visitor, SqlCall call, boolean onlyExpressions, SqlBasicVisitor.ArgHandler<R> argHandler)
Accepts aSqlVisitor
, directing anSqlBasicVisitor.ArgHandler
to visit an operand of a call.boolean
checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
Checks that the operand values in aSqlCall
to this operator are valid.RelDataType
deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call)
Derives the type of a call to this operator.java.lang.String
getAllowedSignatures(java.lang.String name)
Returns a string describing the expected operand types of a call, e.g.private SqlSingleOperandTypeChecker
getChecker(RelDataType operandType)
SqlOperandCountRange
getOperandCountRange()
Returns a constraint on the number of operands expected by this operator.RelDataType
inferReturnType(SqlOperatorBinding opBinding)
Infers the return type of an invocation of this operator; only called after the number and types of operands have already been validated.SqlSpecialOperator.ReduceResult
reduceExpr(int ordinal, SqlSpecialOperator.TokenSequence list)
Reduces a list of operators and arguments according to the rules of precedence and associativity.void
unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.void
validateCall(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope)
Validates a call to this operator.boolean
validRexOperands(int count, Litmus litmus)
Returns whether the given operands are valid.-
Methods inherited from class org.apache.calcite.sql.SqlSpecialOperator
getSyntax
-
Methods inherited from class org.apache.calcite.sql.SqlOperator
acceptCall, adjustType, allowsFraming, argumentMustBeScalar, checkOperandCount, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, createCall, equals, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getMonotonicity, getName, getNameAsId, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, hashCode, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, leftPrec, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands
-
-
-
-
Method Detail
-
reduceExpr
public SqlSpecialOperator.ReduceResult reduceExpr(int ordinal, SqlSpecialOperator.TokenSequence list)
Description copied from class:SqlSpecialOperator
Reduces a list of operators and arguments according to the rules of precedence and associativity. Returns the ordinal of the node which replaced the expression.The default implementation throws
UnsupportedOperationException
.- Overrides:
reduceExpr
in classSqlSpecialOperator
- Parameters:
ordinal
- indicating the ordinal of the current operator in the list on which a possible reduction can be madelist
- List of alternatingSqlParserUtil.ToTreeListItem
andSqlNode
- Returns:
- ordinal of the node which replaced the expression
-
unparse
public void unparse(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
Description copied from class:SqlOperator
Writes a SQL representation of a call to this operator to a writer, including parentheses if the operators on either side are of greater precedence.The default implementation of this method delegates to
SqlSyntax.unparse(org.apache.calcite.sql.SqlWriter, org.apache.calcite.sql.SqlOperator, org.apache.calcite.sql.SqlCall, int, int)
.- Overrides:
unparse
in classSqlOperator
-
getOperandCountRange
public SqlOperandCountRange getOperandCountRange()
Description copied from class:SqlOperator
Returns a constraint on the number of operands expected by this operator. Subclasses may override this method; when they don't, the range is derived from theSqlOperandTypeChecker
associated with this operator.- Overrides:
getOperandCountRange
in classSqlOperator
- Returns:
- acceptable range
-
acceptCall
public <R> void acceptCall(SqlVisitor<R> visitor, SqlCall call, boolean onlyExpressions, SqlBasicVisitor.ArgHandler<R> argHandler)
Description copied from class:SqlOperator
Accepts aSqlVisitor
, directing anSqlBasicVisitor.ArgHandler
to visit an operand of a call.The argument handler allows fine control about how the operands are visited, and how the results are combined.
- Overrides:
acceptCall
in classSqlOperator
- Parameters:
visitor
- Visitorcall
- Call to visitonlyExpressions
- If true, ignores operands which are not expressions. For example, in the call to theAS
operatorargHandler
- Called for each operand
-
deriveType
public RelDataType deriveType(SqlValidator validator, SqlValidatorScope scope, SqlCall call)
Description copied from class:SqlOperator
Derives the type of a call to this operator.This method is an intrinsic part of the validation process so, unlike
SqlOperator.inferReturnType(org.apache.calcite.sql.SqlOperatorBinding)
, specific operators would not typically override this method.- Overrides:
deriveType
in classSqlOperator
- Parameters:
validator
- Validatorscope
- Scope of validationcall
- Call to this operator- Returns:
- Type of call
-
validateCall
public void validateCall(SqlCall call, SqlValidator validator, SqlValidatorScope scope, SqlValidatorScope operandScope)
Description copied from class:SqlOperator
Validates a call to this operator.This method should not perform type-derivation or perform validation related related to types. That is done later, by
SqlOperator.deriveType(SqlValidator, SqlValidatorScope, SqlCall)
. This method should focus on structural validation.A typical implementation of this method first validates the operands, then performs some operator-specific logic. The default implementation just validates the operands.
This method is the default implementation of
SqlCall.validate(org.apache.calcite.sql.validate.SqlValidator, org.apache.calcite.sql.validate.SqlValidatorScope)
; but note that some sub-classes ofSqlCall
never call this method.- Overrides:
validateCall
in classSqlOperator
- Parameters:
call
- the call to this operatorvalidator
- the active validatorscope
- validator scopeoperandScope
- validator scope in which to validate operands to this call; usually equal to scope, but not always because some operators introduce new scopes- See Also:
SqlNode.validateExpr(SqlValidator, SqlValidatorScope)
,SqlOperator.deriveType(SqlValidator, SqlValidatorScope, SqlCall)
-
checkOperandTypes
public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
Description copied from class:SqlOperator
Checks that the operand values in aSqlCall
to this operator are valid. Subclasses must either override this method or supply an instance ofSqlOperandTypeChecker
to the constructor.- Overrides:
checkOperandTypes
in classSqlOperator
- Parameters:
callBinding
- description of callthrowOnFailure
- whether to throw an exception if check fails (otherwise returns false in that case)- Returns:
- whether check succeeded
-
getChecker
private SqlSingleOperandTypeChecker getChecker(RelDataType operandType)
-
validRexOperands
public boolean validRexOperands(int count, Litmus litmus)
Description copied from class:SqlOperator
Returns whether the given operands are valid. If not valid andfail
, throws an assertion error.Similar to
SqlOperator.checkOperandCount(org.apache.calcite.sql.validate.SqlValidator, org.apache.calcite.sql.type.SqlOperandTypeChecker, org.apache.calcite.sql.SqlCall)
, but some operators may have different valid operands inSqlNode
andRexNode
formats (some examples are CAST and AND), and this method throws internal errors, not user errors.- Overrides:
validRexOperands
in classSqlOperator
-
getAllowedSignatures
public java.lang.String getAllowedSignatures(java.lang.String name)
Description copied from class:SqlOperator
Returns a string describing the expected operand types of a call, e.g. "SUBSTRING(VARCHAR, INTEGER, INTEGER)" where the name (SUBSTRING in this example) can be replaced by a specified name.- Overrides:
getAllowedSignatures
in classSqlOperator
-
inferReturnType
public RelDataType inferReturnType(SqlOperatorBinding opBinding)
Description copied from class:SqlOperator
Infers the return type of an invocation of this operator; only called after the number and types of operands have already been validated. Subclasses must either override this method or supply an instance ofSqlReturnTypeInference
to the constructor.- Overrides:
inferReturnType
in classSqlOperator
- Parameters:
opBinding
- description of invocation (not necessarily aSqlCall
)- Returns:
- inferred return type
-
-