Class SqlLikeOperator
LIKE
and SIMILAR
operators.
Syntax of the two operators:
src-value [NOT] LIKE pattern-value [ESCAPE escape-value]
src-value [NOT] SIMILAR pattern-value [ESCAPE escape-value]
NOTE If the NOT
clause is present the
parser
will generate a
equivalent to NOT (src LIKE pattern ...)
-
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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
checkOperandTypes
(SqlCallBinding callBinding, boolean throwOnFailure) Checks that the operand values in aSqlCall
to this operator are valid.Returns a constraint on the number of operands expected by this operator.boolean
Returns whether this operator matches the case of its operands.boolean
Returns whether this is the 'NOT LIKE' operator.not()
Returns the operator that is the logical inverse of this operator.reduceExpr
(int opOrdinal, SqlSpecialOperator.TokenSequence list) Reduces a list of operators and arguments according to the rules of precedence and associativity.void
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, acceptCall, adjustType, allowsFraming, argumentMustBeScalar, checkOperandCount, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, createCall, createCall, createCall, createCall, deriveOperandType, deriveType, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getMonotonicity, getName, getNameAsId, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, getStrongPolicyInference, hashCode, inferReturnType, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, isSymmetrical, leftPrec, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, reverse, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateOperands
-
Method Details
-
isNegated
public boolean isNegated()Returns whether this is the 'NOT LIKE' operator.- Returns:
- whether this is 'NOT LIKE'
- See Also:
-
isCaseSensitive
public boolean isCaseSensitive()Returns whether this operator matches the case of its operands. For example, returns true forLIKE
and false forILIKE
.- Returns:
- whether this operator matches the case of its operands
-
not
Description copied from class:SqlOperator
Returns the operator that is the logical inverse of this operator.For example,
SqlStdOperatorTable.LIKE.not()
returnsSqlStdOperatorTable.NOT_LIKE
, and vice versa.By default, returns
null
, which means there is no inverse operator.- Overrides:
not
in classSqlOperator
- See Also:
-
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
-
checkOperandTypes
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
-
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:
-
validRexOperands
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
-
unparse
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
-
reduceExpr
public SqlSpecialOperator.ReduceResult reduceExpr(int opOrdinal, 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:
opOrdinal
- 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
-