Package org.apache.calcite.sql
Class SqlOperatorBinding
java.lang.Object
org.apache.calcite.sql.SqlOperatorBinding
- Direct Known Subclasses:
Aggregate.AggCallBinding
,ExplicitOperatorBinding
,RexCallBinding
,SqlCallBinding
SqlOperatorBinding
represents the binding of an
SqlOperator
to actual operands, along with any additional information
required to validate those operands if needed.-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
SqlOperatorBinding
(RelDataTypeFactory typeFactory, SqlOperator sqlOperator) Creates a SqlOperatorBinding. -
Method Summary
Modifier and TypeMethodDescriptionCollects the types of the bound operands into a list.Returns the collation type.@Nullable String
getColumnListParamInfo
(int ordinal, String paramName, List<String> columnList) Retrieves information about a column list parameter.@Nullable RelDataType
getCursorOperand
(int ordinal) Returns the rowtype of theordinal
th operand, which is a cursor.int
If the operator call occurs in an aggregate query, returns the number of columns in the GROUP BY clause.int
getIntLiteralOperand
(int ordinal) Deprecated.abstract int
Returns the number of bound operands.@Nullable Comparable
getOperandLiteralValue
(int ordinal) Deprecated.<T> @Nullable T
getOperandLiteralValue
(int ordinal, Class<T> clazz) Gets the value of a literal operand.@Nullable Object
getOperandLiteralValue
(int ordinal, RelDataType type) Gets the value of a literal operand as a Calcite type.getOperandMonotonicity
(int ordinal) Gets the monotonicity of a bound operand.abstract RelDataType
getOperandType
(int ordinal) Gets the type of a bound operand.Returns the bound operator.int
Returns the number of pre-operands.@Nullable String
getStringLiteralOperand
(int ordinal) Deprecated.Returns the factory for type creation.boolean
Returns whether the operator is an aggregate function with a filter.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.boolean
isOperandTimeFrame
(int ordinal) Returns whether an operand is a time frame.abstract CalciteException
newError
(org.apache.calcite.runtime.Resources.ExInst<SqlValidatorException> e) Wraps a validation error with context appropriate to this operator call.transform
(SqlTypeTransform typeTransform) Returns an operator binding equivalent that is equivalent to this except that a transform has been applied to each operand type.
-
Field Details
-
typeFactory
-
-
Constructor Details
-
SqlOperatorBinding
Creates a SqlOperatorBinding.- Parameters:
typeFactory
- Type factorysqlOperator
- Operator which is subject of this call
-
-
Method Details
-
getGroupCount
public int getGroupCount()If the operator call occurs in an aggregate query, returns the number of columns in the GROUP BY clause. For example, for "SELECT count(*) FROM emp GROUP BY deptno, gender", returns 2.Returns 0 if the query is implicitly "GROUP BY ()" because of an aggregate expression. For example, "SELECT sum(sal) FROM emp".
Returns -1 if the query is not an aggregate query.
-
hasFilter
public boolean hasFilter()Returns whether the operator is an aggregate function with a filter. -
getOperator
Returns the bound operator. -
getTypeFactory
Returns the factory for type creation. -
getStringLiteralOperand
Deprecated.Gets the string value of a string literal operand.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- string value
-
getIntLiteralOperand
Deprecated.Gets the integer value of a numeric literal operand.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- integer value
-
getOperandLiteralValue
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.
- Parameters:
ordinal
- zero-based ordinal of operand of interestclazz
- Desired valued type- Returns:
- value of operand
-
getOperandLiteralValue
Gets the value of a literal operand as a Calcite type.- Parameters:
ordinal
- zero-based ordinal of operand of interesttype
- Desired valued type- Returns:
- value of operand
-
getOperandLiteralValue
Deprecated. -
isOperandNull
public boolean isOperandNull(int ordinal, boolean allowCast) Determines whether a bound operand is NULL.This is only relevant for SQL validation.
- 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) Determines whether an operand is a literal.- Parameters:
ordinal
- zero-based ordinal of operand of interestallowCast
- whether to regard CAST(literal) as a literal- Returns:
- whether operand is literal
-
isOperandTimeFrame
public boolean isOperandTimeFrame(int ordinal) Returns whether an operand is a time frame.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- whether operand is a time frame
-
getOperandCount
public abstract int getOperandCount()Returns the number of bound operands. Includes pre-operands and regular operands. -
getPreOperandCount
public int getPreOperandCount()Returns the number of pre-operands. Zero except for a few aggregate functions. -
getOperandType
Gets the type of a bound operand.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- bound operand type
-
getOperandMonotonicity
Gets the monotonicity of a bound operand.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- monotonicity of operand
-
getCollationType
Returns the collation type. -
collectOperandTypes
Collects the types of the bound operands into a list.- Returns:
- collected list
-
getCursorOperand
Returns the rowtype of theordinal
th operand, which is a cursor.This is only implemented for
SqlCallBinding
.- Parameters:
ordinal
- Ordinal of the operand- Returns:
- Rowtype of the query underlying the cursor
-
getColumnListParamInfo
public @Nullable String getColumnListParamInfo(int ordinal, String paramName, List<String> columnList) Retrieves information about a column list parameter.- Parameters:
ordinal
- ordinal position of the column list parameterparamName
- name of the column list parametercolumnList
- returns a list of the column names that are referenced in the column list parameter- Returns:
- the name of the parent cursor referenced by the column list parameter if it is a column list parameter; otherwise, null is returned
-
newError
public abstract CalciteException newError(org.apache.calcite.runtime.Resources.ExInst<SqlValidatorException> e) Wraps a validation error with context appropriate to this operator call.- Parameters:
e
- Validation error, not null- Returns:
- Error wrapped, if possible, with positional information
-
transform
Returns an operator binding equivalent that is equivalent to this except that a transform has been applied to each operand type.
-