Package org.apache.calcite.sql
Class SqlCallBinding
- java.lang.Object
-
- org.apache.calcite.sql.SqlOperatorBinding
-
- org.apache.calcite.sql.SqlCallBinding
-
public class SqlCallBinding extends SqlOperatorBinding
SqlCallBinding
implementsSqlOperatorBinding
by analyzing to the operands of aSqlCall
with aSqlValidator
.
-
-
Field Summary
Fields Modifier and Type Field Description private SqlCall
call
private static SqlCall
DEFAULT_CALL
private SqlValidatorScope
scope
private SqlValidator
validator
-
Fields inherited from class org.apache.calcite.sql.SqlOperatorBinding
typeFactory
-
-
Constructor Summary
Constructors Constructor Description SqlCallBinding(SqlValidator validator, SqlValidatorScope scope, SqlCall call)
Creates a call binding.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlCall
getCall()
Returns the call node.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)
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.SqlValidatorScope
getScope()
Returns the scope of the call.java.lang.String
getStringLiteralOperand(int ordinal)
Gets the string value of a string literal operand.SqlValidator
getValidator()
Returns the validator.private boolean
hasAssignment()
Returns whether arguments have name assignment.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.CalciteException
newValidationError(Resources.ExInst<SqlValidatorException> ex)
Constructs a new validation error for the call.CalciteException
newValidationSignatureError()
Constructs a new validation signature error for the call.SqlNode
operand(int i)
Returns a particular operand.java.util.List<SqlNode>
operands()
Returns the operands to a call permuted into the same order as the formal parameters of the function.SqlCall
permutedCall()
Returns a call that is equivalent except that arguments have been permuted into the logical order.private java.util.List<SqlNode>
permutedOperands(SqlCall call)
Returns the operands to a call permuted into the same order as the formal parameters of the function.-
Methods inherited from class org.apache.calcite.sql.SqlOperatorBinding
collectOperandTypes, getOperandLiteralValue, getOperator, getTypeFactory, hasFilter
-
-
-
-
Field Detail
-
DEFAULT_CALL
private static final SqlCall DEFAULT_CALL
-
validator
private final SqlValidator validator
-
scope
private final SqlValidatorScope scope
-
call
private final SqlCall call
-
-
Constructor Detail
-
SqlCallBinding
public SqlCallBinding(SqlValidator validator, SqlValidatorScope scope, SqlCall call)
Creates a call binding.- Parameters:
validator
- Validatorscope
- Scope of callcall
- Call node
-
-
Method Detail
-
getGroupCount
public int getGroupCount()
Description copied from class:SqlOperatorBinding
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.
- Overrides:
getGroupCount
in classSqlOperatorBinding
-
getValidator
public SqlValidator getValidator()
Returns the validator.
-
getScope
public SqlValidatorScope getScope()
Returns the scope of the call.
-
getCall
public SqlCall getCall()
Returns the call node.
-
operands
public java.util.List<SqlNode> operands()
Returns the operands to a call permuted into the same order as the formal parameters of the function.
-
hasAssignment
private boolean hasAssignment()
Returns whether arguments have name assignment.
-
permutedOperands
private java.util.List<SqlNode> permutedOperands(SqlCall call)
Returns the operands to a call permuted into the same order as the formal parameters of the function.
-
operand
public SqlNode operand(int i)
Returns a particular operand.
-
permutedCall
public SqlCall permutedCall()
Returns a call that is equivalent except that arguments have been permuted into the logical order. Any arguments whose default value is being used are null.
-
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
-
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
-
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
-
getCursorOperand
public RelDataType getCursorOperand(int ordinal)
Description copied from class:SqlOperatorBinding
Returns the rowtype of theordinal
th operand, which is a cursor.This is only implemented for
SqlCallBinding
.- Overrides:
getCursorOperand
in classSqlOperatorBinding
- 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)
Description copied from class:SqlOperatorBinding
Retrieves information about a column list parameter.- Overrides:
getColumnListParamInfo
in classSqlOperatorBinding
- 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 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
-
newValidationSignatureError
public CalciteException newValidationSignatureError()
Constructs a new validation signature error for the call.- Returns:
- signature exception
-
newValidationError
public CalciteException newValidationError(Resources.ExInst<SqlValidatorException> ex)
Constructs a new validation error for the call. (Do not use this to construct a validation error for other nodes such as an operands.)- Parameters:
ex
- underlying exception- Returns:
- wrapped exception
-
-