Package org.apache.calcite.sql.fun
Class SqlLikeOperator
- java.lang.Object
-
- org.apache.calcite.sql.SqlOperator
-
- org.apache.calcite.sql.SqlSpecialOperator
-
- org.apache.calcite.sql.fun.SqlLikeOperator
-
public class SqlLikeOperator extends SqlSpecialOperator
An operator describing theLIKE
andSIMILAR
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 theparser
will generate a equivalent toNOT (src LIKE pattern ...)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.calcite.sql.SqlSpecialOperator
SqlSpecialOperator.ReduceResult, SqlSpecialOperator.TokenSequence
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
negated
-
Fields inherited from class org.apache.calcite.sql.SqlOperator
kind, MDX_PRECEDENCE, NL
-
-
Constructor Summary
Constructors Constructor Description SqlLikeOperator(java.lang.String name, SqlKind kind, boolean negated)
Creates a SqlLikeOperator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
Checks that the operand values in aSqlCall
to this operator are valid.SqlOperandCountRange
getOperandCountRange()
Returns a constraint on the number of operands expected by this operator.boolean
isNegated()
Returns whether this is the 'NOT LIKE' operator.SqlSpecialOperator.ReduceResult
reduceExpr(int opOrdinal, 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.-
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, deriveType, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getMonotonicity, getName, getNameAsId, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, hashCode, inferReturnType, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, leftPrec, preValidateCall, requiresDecimalExpansion, requiresOrder, requiresOver, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateCall, validateOperands, validRexOperands
-
-
-
-
Constructor Detail
-
SqlLikeOperator
SqlLikeOperator(java.lang.String name, SqlKind kind, boolean negated)
Creates a SqlLikeOperator.- Parameters:
name
- Operator namekind
- Kindnegated
- Whether this is 'NOT LIKE'
-
-
Method Detail
-
isNegated
public boolean isNegated()
Returns whether this is the 'NOT LIKE' operator.- Returns:
- whether this is 'NOT LIKE'
-
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
-
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
-
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
-
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
-
-