Package org.apache.calcite.sql
Class SqlOperatorBinding
- java.lang.Object
-
- org.apache.calcite.sql.SqlOperatorBinding
-
- Direct Known Subclasses:
Aggregate.AggCallBinding
,ExplicitOperatorBinding
,RexCallBinding
,SqlCallBinding
public abstract class SqlOperatorBinding extends java.lang.Object
SqlOperatorBinding
represents the binding of anSqlOperator
to actual operands, along with any additional information required to validate those operands if needed.
-
-
Field Summary
Fields Modifier and Type Field Description private SqlOperator
sqlOperator
protected RelDataTypeFactory
typeFactory
-
Constructor Summary
Constructors Modifier Constructor Description protected
SqlOperatorBinding(RelDataTypeFactory typeFactory, SqlOperator sqlOperator)
Creates a SqlOperatorBinding.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.List<RelDataType>
collectOperandTypes()
Collects the types of the bound operands into a list.java.lang.String
getColumnListParamInfo(int ordinal, java.lang.String paramName, java.util.List<java.lang.String> columnList)
Retrieves information about a column list parameter.RelDataType
getCursorOperand(int ordinal)
Returns the rowtype of theordinal
th operand, which is a cursor.int
getGroupCount()
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
getOperandCount()
java.lang.Comparable
getOperandLiteralValue(int ordinal)
Deprecated.<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.abstract RelDataType
getOperandType(int ordinal)
Gets the type of a bound operand.SqlOperator
getOperator()
java.lang.String
getStringLiteralOperand(int ordinal)
Deprecated.RelDataTypeFactory
getTypeFactory()
boolean
hasFilter()
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.abstract CalciteException
newError(Resources.ExInst<SqlValidatorException> e)
Wraps a validation error with context appropriate to this operator call.
-
-
-
Field Detail
-
typeFactory
protected final RelDataTypeFactory typeFactory
-
sqlOperator
private final SqlOperator sqlOperator
-
-
Constructor Detail
-
SqlOperatorBinding
protected SqlOperatorBinding(RelDataTypeFactory typeFactory, SqlOperator sqlOperator)
Creates a SqlOperatorBinding.- Parameters:
typeFactory
- Type factorysqlOperator
- Operator which is subject of this call
-
-
Method Detail
-
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
public SqlOperator getOperator()
- Returns:
- bound operator
-
getTypeFactory
public RelDataTypeFactory getTypeFactory()
- Returns:
- factory for type creation
-
getStringLiteralOperand
@Deprecated public java.lang.String getStringLiteralOperand(int ordinal)
Deprecated.Gets the string value of a string literal operand.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- string value
-
getIntLiteralOperand
@Deprecated public int getIntLiteralOperand(int ordinal)
Deprecated.Gets the integer value of a numeric literal operand.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- integer value
-
getOperandLiteralValue
public <T> T getOperandLiteralValue(int ordinal, java.lang.Class<T> clazz)
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
@Deprecated public java.lang.Comparable getOperandLiteralValue(int ordinal)
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
-
getOperandCount
public abstract int getOperandCount()
- Returns:
- the number of bound operands
-
getOperandType
public abstract RelDataType getOperandType(int ordinal)
Gets the type of a bound operand.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- bound operand type
-
getOperandMonotonicity
public SqlMonotonicity getOperandMonotonicity(int ordinal)
Gets the monotonicity of a bound operand.- Parameters:
ordinal
- zero-based ordinal of operand of interest- Returns:
- monotonicity of operand
-
collectOperandTypes
public java.util.List<RelDataType> collectOperandTypes()
Collects the types of the bound operands into a list.- Returns:
- collected list
-
getCursorOperand
public RelDataType getCursorOperand(int ordinal)
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 java.lang.String getColumnListParamInfo(int ordinal, java.lang.String paramName, java.util.List<java.lang.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(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
-
-