Package org.apache.calcite.rex
Class RexCallBinding
- java.lang.Object
-
- org.apache.calcite.sql.SqlOperatorBinding
-
- org.apache.calcite.rex.RexCallBinding
-
- Direct Known Subclasses:
RexCallBinding.RexCastCallBinding
public class RexCallBinding extends SqlOperatorBinding
RexCallBinding
implementsSqlOperatorBinding
by referring to an underlying collection ofRexNode
operands.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RexCallBinding.RexCastCallBinding
To be compatible withSqlCall
, CAST needs to pretend that it has two arguments, the second of which is the target type.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<RelCollation>
inputCollations
private java.util.List<RexNode>
operands
-
Fields inherited from class org.apache.calcite.sql.SqlOperatorBinding
typeFactory
-
-
Constructor Summary
Constructors Constructor Description RexCallBinding(RelDataTypeFactory typeFactory, SqlOperator sqlOperator, java.util.List<? extends RexNode> operands, java.util.List<RelCollation> inputCollations)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RexCallBinding
create(RelDataTypeFactory typeFactory, RexCall call, java.util.List<RelCollation> inputCollations)
Creates a binding of the appropriate type.int
getIntLiteralOperand(int ordinal)
Gets the integer value of a numeric literal operand.int
getOperandCount()
<T> T
getOperandLiteralValue(int ordinal, java.lang.Class<T> clazz)
Gets the value of a literal operand.SqlMonotonicity
getOperandMonotonicity(int ordinal)
Gets the monotonicity of a bound operand.RelDataType
getOperandType(int ordinal)
Gets the type of a bound operand.java.lang.String
getStringLiteralOperand(int ordinal)
Gets the string value of a string literal operand.boolean
isOperandLiteral(int ordinal, boolean allowCast)
Determines whether an operand is a literal.boolean
isOperandNull(int ordinal, boolean allowCast)
Determines whether a bound operand is NULL.CalciteException
newError(Resources.ExInst<SqlValidatorException> e)
Wraps a validation error with context appropriate to this operator call.-
Methods inherited from class org.apache.calcite.sql.SqlOperatorBinding
collectOperandTypes, getColumnListParamInfo, getCursorOperand, getGroupCount, getOperandLiteralValue, getOperator, getTypeFactory, hasFilter
-
-
-
-
Field Detail
-
operands
private final java.util.List<RexNode> operands
-
inputCollations
private final java.util.List<RelCollation> inputCollations
-
-
Constructor Detail
-
RexCallBinding
public RexCallBinding(RelDataTypeFactory typeFactory, SqlOperator sqlOperator, java.util.List<? extends RexNode> operands, java.util.List<RelCollation> inputCollations)
-
-
Method Detail
-
create
public static RexCallBinding create(RelDataTypeFactory typeFactory, RexCall call, java.util.List<RelCollation> inputCollations)
Creates a binding of the appropriate type.
-
getStringLiteralOperand
public java.lang.String getStringLiteralOperand(int ordinal)
Description copied from class:SqlOperatorBinding
Gets the string value of a string literal operand.- Overrides:
getStringLiteralOperand
in classSqlOperatorBinding
- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- string value
-
getIntLiteralOperand
public int getIntLiteralOperand(int ordinal)
Description copied from class:SqlOperatorBinding
Gets the integer value of a numeric literal operand.- Overrides:
getIntLiteralOperand
in classSqlOperatorBinding
- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- integer value
-
getOperandLiteralValue
public <T> T getOperandLiteralValue(int ordinal, java.lang.Class<T> clazz)
Description copied from class:SqlOperatorBinding
Gets the value of a literal operand.Cases:
- If the operand is not a literal, the value is null.
- If the operand is a string literal,
the value will be of type
NlsString
. - If the operand is a numeric literal,
the value will be of type
BigDecimal
. - If the operand is an interval qualifier,
the value will be of type
SqlIntervalQualifier
- Otherwise the type is undefined, and the value may be null.
- Overrides:
getOperandLiteralValue
in classSqlOperatorBinding
- Parameters:
ordinal
- zero-based ordinal of operand of interestclazz
- Desired valued type- Returns:
- value of operand
-
getOperandMonotonicity
public SqlMonotonicity getOperandMonotonicity(int ordinal)
Description copied from class:SqlOperatorBinding
Gets the monotonicity of a bound operand.- Overrides:
getOperandMonotonicity
in classSqlOperatorBinding
- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- monotonicity of operand
-
isOperandNull
public boolean isOperandNull(int ordinal, boolean allowCast)
Description copied from class:SqlOperatorBinding
Determines whether a bound operand is NULL.This is only relevant for SQL validation.
- Overrides:
isOperandNull
in classSqlOperatorBinding
- Parameters:
ordinal
- zero-based ordinal of operand of interestallowCast
- whether to regard CAST(constant) as a constant- Returns:
- whether operand is null; false for everything except SQL validation
-
isOperandLiteral
public boolean isOperandLiteral(int ordinal, boolean allowCast)
Description copied from class:SqlOperatorBinding
Determines whether an operand is a literal.- Overrides:
isOperandLiteral
in classSqlOperatorBinding
- Parameters:
ordinal
- zero-based ordinal of operand of interestallowCast
- whether to regard CAST(literal) as a literal- Returns:
- whether operand is literal
-
getOperandCount
public int getOperandCount()
- Specified by:
getOperandCount
in classSqlOperatorBinding
- Returns:
- the number of bound operands
-
getOperandType
public RelDataType getOperandType(int ordinal)
Description copied from class:SqlOperatorBinding
Gets the type of a bound operand.- Specified by:
getOperandType
in classSqlOperatorBinding
- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- bound operand type
-
newError
public CalciteException newError(Resources.ExInst<SqlValidatorException> e)
Description copied from class:SqlOperatorBinding
Wraps a validation error with context appropriate to this operator call.- Specified by:
newError
in classSqlOperatorBinding
- Parameters:
e
- Validation error, not null- Returns:
- Error wrapped, if possible, with positional information
-
-