Class SqlLiteralChainOperator
- java.lang.Object
-
- org.apache.calcite.sql.SqlOperator
-
- org.apache.calcite.sql.SqlSpecialOperator
-
- org.apache.calcite.sql.fun.SqlLiteralChainOperator
-
public class SqlLiteralChainOperator extends SqlSpecialOperator
Internal operator, by which the parser represents a continued string literal.The string fragments are
SqlLiteral
objects, all of the same type, collected as the operands of anSqlCall
using this operator. After validation, the fragments will be concatenated into a single literal.For a chain of
SqlCharStringLiteral
objects, aSqlCollation
object is attached only to the head of the chain.
-
-
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 SqlLiteralChainOperator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
argTypesValid(SqlCallBinding callBinding)
boolean
checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
Checks that the operand values in aSqlCall
to this operator are valid.static SqlLiteral
concatenateOperands(SqlCall call)
Concatenates the operands of a call to this operator.java.lang.String
getAllowedSignatures(java.lang.String opName)
Returns a string describing the expected operand types of a call, e.g.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.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.-
Methods inherited from class org.apache.calcite.sql.SqlSpecialOperator
getSyntax, reduceExpr
-
Methods inherited from class org.apache.calcite.sql.SqlOperator
acceptCall, acceptCall, adjustType, allowsFraming, argumentMustBeScalar, checkOperandCount, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, createCall, deriveType, equals, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getMonotonicity, getName, getNameAsId, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, hashCode, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, leftPrec, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands, validRexOperands
-
-
-
-
Method Detail
-
argTypesValid
private boolean argTypesValid(SqlCallBinding callBinding)
-
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
-
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
-
getAllowedSignatures
public java.lang.String getAllowedSignatures(java.lang.String opName)
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
-
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)
-
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
-
concatenateOperands
public static SqlLiteral concatenateOperands(SqlCall call)
Concatenates the operands of a call to this operator.
-
-