Package org.apache.calcite.sql
Class SqlCallBinding
java.lang.Object
org.apache.calcite.sql.SqlOperatorBinding
org.apache.calcite.sql.SqlCallBinding
- Direct Known Subclasses:
SqlWithinGroupOperator.PercentileDiscCallBinding
SqlCallBinding implements SqlOperatorBinding by
analyzing to the operands of a SqlCall with a SqlValidator.-
Field Summary
Fields inherited from class org.apache.calcite.sql.SqlOperatorBinding
typeFactory -
Constructor Summary
ConstructorsConstructorDescriptionSqlCallBinding(SqlValidator validator, SqlValidatorScope scope, SqlCall call) Creates a call binding. -
Method Summary
Modifier and TypeMethodDescriptiongetCall()Returns the call node.@Nullable StringgetColumnListParamInfo(int ordinal, String paramName, List<String> columnList) Retrieves information about a column list parameter.@Nullable RelDataTypegetCursorOperand(int ordinal) Returns the rowtype of theordinalth operand, which is a cursor.intIf the operator call occurs in an aggregate query, returns the number of columns in the GROUP BY clause.intgetIntLiteralOperand(int ordinal) Gets the integer value of a numeric literal operand.intReturns the number of bound operands.<T> @Nullable TgetOperandLiteralValue(int ordinal, Class<T> clazz) Gets the value of a literal operand.getOperandMonotonicity(int ordinal) Gets the monotonicity of a bound operand.getOperandType(int ordinal) Gets the type of a bound operand.getScope()Returns the scope of the call.@Nullable StringgetStringLiteralOperand(int ordinal) Gets the string value of a string literal operand.Returns the validator.booleanisOperandLiteral(int ordinal, boolean allowCast) Determines whether an operand is a literal.booleanisOperandNull(int ordinal, boolean allowCast) Determines whether a bound operand is NULL.booleanReturns whether to allow implicit type coercion when validation.newError(org.apache.calcite.runtime.Resources.ExInst<SqlValidatorException> e) Wraps a validation error with context appropriate to this operator call.newValidationError(org.apache.calcite.runtime.Resources.ExInst<SqlValidatorException> ex) Constructs a new validation error for the call.Constructs a new validation signature error for the call.operand(int i) Returns a particular operand.operands()Returns the operands to a call permuted into the same order as the formal parameters of the function.Returns a call that is equivalent except that arguments have been permuted into the logical order.Methods inherited from class org.apache.calcite.sql.SqlOperatorBinding
collectOperandTypes, getCollationType, getOperandLiteralValue, getOperandLiteralValue, getOperator, getPreOperandCount, getTypeFactory, hasFilter, isOperandTimeFrame, transform
-
Constructor Details
-
SqlCallBinding
Creates a call binding.- Parameters:
validator- Validatorscope- Scope of callcall- Call node
-
-
Method Details
-
getGroupCount
public int getGroupCount()Description copied from class:SqlOperatorBindingIf 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:
getGroupCountin classSqlOperatorBinding
-
getValidator
Returns the validator. -
getScope
Returns the scope of the call. -
getCall
Returns the call node. -
operands
Returns the operands to a call permuted into the same order as the formal parameters of the function. -
operand
Returns a particular operand. -
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
Description copied from class:SqlOperatorBindingGets the monotonicity of a bound operand.- Overrides:
getOperandMonotonicityin classSqlOperatorBinding- Parameters:
ordinal- zero-based ordinal of operand of interest- Returns:
- monotonicity of operand
-
getStringLiteralOperand
Description copied from class:SqlOperatorBindingGets the string value of a string literal operand.- Overrides:
getStringLiteralOperandin classSqlOperatorBinding- Parameters:
ordinal- zero-based ordinal of operand of interest- Returns:
- string value
-
getIntLiteralOperand
public int getIntLiteralOperand(int ordinal) Description copied from class:SqlOperatorBindingGets the integer value of a numeric literal operand.- Overrides:
getIntLiteralOperandin classSqlOperatorBinding- Parameters:
ordinal- zero-based ordinal of operand of interest- Returns:
- integer value
-
getOperandLiteralValue
Description copied from class:SqlOperatorBindingGets 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:
getOperandLiteralValuein 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:SqlOperatorBindingDetermines whether a bound operand is NULL.This is only relevant for SQL validation.
- Overrides:
isOperandNullin 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:SqlOperatorBindingDetermines whether an operand is a literal.- Overrides:
isOperandLiteralin 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()Description copied from class:SqlOperatorBindingReturns the number of bound operands. Includes pre-operands and regular operands.- Specified by:
getOperandCountin classSqlOperatorBinding
-
getOperandType
Description copied from class:SqlOperatorBindingGets the type of a bound operand.- Specified by:
getOperandTypein classSqlOperatorBinding- Parameters:
ordinal- zero-based ordinal of operand of interest- Returns:
- bound operand type
-
getCursorOperand
Description copied from class:SqlOperatorBindingReturns the rowtype of theordinalth operand, which is a cursor.This is only implemented for
SqlCallBinding.- Overrides:
getCursorOperandin classSqlOperatorBinding- 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) Description copied from class:SqlOperatorBindingRetrieves information about a column list parameter.- Overrides:
getColumnListParamInfoin 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(org.apache.calcite.runtime.Resources.ExInst<SqlValidatorException> e) Description copied from class:SqlOperatorBindingWraps a validation error with context appropriate to this operator call.- Specified by:
newErrorin classSqlOperatorBinding- Parameters:
e- Validation error, not null- Returns:
- Error wrapped, if possible, with positional information
-
newValidationSignatureError
Constructs a new validation signature error for the call.- Returns:
- signature exception
-
newValidationError
public CalciteException newValidationError(org.apache.calcite.runtime.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
-
isTypeCoercionEnabled
public boolean isTypeCoercionEnabled()Returns whether to allow implicit type coercion when validation. This is a short-cut method.
-