Package org.apache.calcite.sql.advise
Class SqlAdvisorValidator
java.lang.Object
org.apache.calcite.sql.validate.SqlValidatorImpl
org.apache.calcite.sql.advise.SqlAdvisorValidator
- All Implemented Interfaces:
SqlValidator,SqlValidatorWithHints
SqlAdvisorValidator is used by SqlAdvisor to traverse
the parse tree of a SQL statement, not for validation purpose but for setting
up the scopes and namespaces to facilitate retrieval of SQL statement
completion hints.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.calcite.sql.validate.SqlValidatorImpl
SqlValidatorImpl.DmlNamespace, SqlValidatorImpl.FunctionParamInfo, SqlValidatorImpl.IdInfo, SqlValidatorImpl.StatusNested classes/interfaces inherited from interface org.apache.calcite.sql.validate.SqlValidator
SqlValidator.Config -
Field Summary
Fields inherited from class org.apache.calcite.sql.validate.SqlValidatorImpl
callToOperandTypesMap, functionCallStack, idPositions, namespaces, scopes, timeFrameSet, TRACER, typeFactory, unknownType, UPDATE_ANON_PREFIX, UPDATE_SRC_ALIAS, UPDATE_TGT_ALIAS -
Constructor Summary
ConstructorsConstructorDescriptionSqlAdvisorValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlValidator.Config config) Creates a SqlAdvisor validator. -
Method Summary
Modifier and TypeMethodDescriptionderiveType(SqlValidatorScope scope, SqlNode operand) Calls the parent class method and mask Farrago exception thrown.expand(SqlNode expr, SqlValidatorScope scope) Expands an expression.expandOrderExpr(SqlSelect select, SqlNode orderExpr) Expands an expression in the ORDER BY clause into an expression with the same semantics as expressions in the SELECT clause.expandSelectExpr(SqlNode expr, SelectScope scope, SqlSelect select, Map<String, SqlNode> expansions) protected booleanprotected voidvalidateFrom(SqlNode node, RelDataType targetRowType, SqlValidatorScope scope) Validates the FROM clause of a query, or (recursively) a child node of the FROM clause: AS, OVER, JOIN, VALUES, or sub-query.protected voidvalidateHavingClause(SqlSelect select) Calls the parent class method and masks Farrago exception thrown.voidvalidateIdentifier(SqlIdentifier id, SqlValidatorScope scope) Registers the identifier and its scope into a map keyed by ParserPosition.booleanvalidateModality(SqlSelect select, SqlModality modality, boolean fail) Validates that a query is capable of producing a return of given modality (relational or streaming).protected voidvalidateNamespace(SqlValidatorNamespace namespace, RelDataType targetRowType) Validates a namespace.protected voidvalidateOver(SqlCall call, SqlValidatorScope scope) protected voidvalidateWhereClause(SqlSelect select) Calls the parent class method and masks Farrago exception thrown.Methods inherited from class org.apache.calcite.sql.validate.SqlValidatorImpl
addToSelectList, checkTypeAssignment, config, createMatchRecognizeNameSpace, createPivotNameSpace, createSelectNamespace, createSetopNamespace, createSourceSelectForDelete, createSourceSelectForUpdate, createTargetRowType, createUnpivotNameSpace, declareCursor, deriveAlias, deriveConstructorType, expandStar, extendedExpandGroupBy, getAggregate, getCatalogReader, getConformance, getCursorScope, getEmptyScope, getFieldOrigins, getFromScope, getGroupScope, getHavingScope, getJoinScope, getLambdaScope, getLogicalSourceRowType, getLogicalTargetRowType, getMatchRecognizeScope, getMeasureScope, getNamespace, getOperatorTable, getOrderScope, getOriginal, getOverScope, getParameterRowType, getParentCursor, getRawSelectScope, getSelectScope, getSelfJoinExprForUpdate, getTimeFrameSet, getTypeCoercion, getTypeFactory, getUnknownType, getValidatedNodeType, getValidatedNodeTypeIfKnown, getValidatedOperandTypes, getValidationErrorFunction, getWhereScope, getWindowByName, getWithScope, handleUnresolvedFunction, inferUnknownTypes, isAggregate, isAggregate, isNestedAggregateWindow, isOverAggregateWindow, isSystemField, lookupHints, lookupNameCompletionHints, lookupQualifiedName, makeNullaryCall, newValidationError, performUnconditionalRewrites, popFunctionCall, pushFunctionCall, registerNamespace, registerQuery, removeValidatedNodeType, resolveLiteral, resolveWindow, setOriginal, setValidatedNodeType, shouldAllowIntermediateOrderBy, transform, usingNames, validate, validateAggregateParams, validateCall, validateDataType, validateDelete, validateDynamicParam, validateFeature, validateGroupClause, validateInsert, validateIntervalQualifier, validateJoin, validateLambda, validateLiteral, validateMatchRecognize, validateMerge, validateMustFilterRequirements, validateOrderList, validateParameterizedExpression, validatePivot, validateQualifyClause, validateQuery, validateSelect, validateSelectList, validateSequenceValue, validateTableFunction, validateTimeFrame, validateUnnest, validateUnpivot, validateUpdate, validateValues, validateWhereOrOn, validateWindow, validateWindowClause, validateWith, validateWithItemMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.calcite.sql.validate.SqlValidator
getTypeMappingRule, resolveWindow
-
Constructor Details
-
SqlAdvisorValidator
public SqlAdvisorValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlValidator.Config config) Creates a SqlAdvisor validator.- Parameters:
opTab- Operator tablecatalogReader- Catalog readertypeFactory- Type factoryconfig- Config
-
-
Method Details
-
validateIdentifier
Registers the identifier and its scope into a map keyed by ParserPosition.- Specified by:
validateIdentifierin interfaceSqlValidator- Overrides:
validateIdentifierin classSqlValidatorImpl- Parameters:
id- Identifierscope- Naming scope
-
expand
Description copied from interface:SqlValidatorExpands an expression.- Specified by:
expandin interfaceSqlValidator- Overrides:
expandin classSqlValidatorImpl- Parameters:
expr- Expressionscope- Scope- Returns:
- Expanded expression
-
expandSelectExpr
public SqlNode expandSelectExpr(SqlNode expr, SelectScope scope, SqlSelect select, Map<String, SqlNode> expansions) - Overrides:
expandSelectExprin classSqlValidatorImpl
-
expandOrderExpr
Description copied from interface:SqlValidatorExpands an expression in the ORDER BY clause into an expression with the same semantics as expressions in the SELECT clause.This is made necessary by a couple of dialect 'features':
- ordinal expressions: In "SELECT x, y FROM t ORDER BY 2", the expression "2" is shorthand for the 2nd item in the select clause, namely "y".
- alias references: In "SELECT x AS a, y FROM t ORDER BY a", the expression "a" is shorthand for the item in the select clause whose alias is "a"
- Specified by:
expandOrderExprin interfaceSqlValidator- Overrides:
expandOrderExprin classSqlValidatorImpl- Parameters:
select- Select statement which contains ORDER BYorderExpr- Expression in the ORDER BY clause.- Returns:
- Expression translated into SELECT clause semantics
-
deriveType
Calls the parent class method and mask Farrago exception thrown.- Specified by:
deriveTypein interfaceSqlValidator- Overrides:
deriveTypein classSqlValidatorImpl- Parameters:
scope- Syntactic scopeoperand- Parse tree node- Returns:
- Type of the SqlNode. Should never return
NULL
-
validateFrom
Description copied from class:SqlValidatorImplValidates the FROM clause of a query, or (recursively) a child node of the FROM clause: AS, OVER, JOIN, VALUES, or sub-query.- Overrides:
validateFromin classSqlValidatorImpl- Parameters:
node- Node in FROM clause, typically a table or derived tabletargetRowType- Desired row type of this expression, orSqlValidatorImpl.unknownTypeif not fussy. Must not be null.scope- Scope
-
validateWhereClause
Calls the parent class method and masks Farrago exception thrown.- Overrides:
validateWhereClausein classSqlValidatorImpl
-
validateHavingClause
Calls the parent class method and masks Farrago exception thrown.- Overrides:
validateHavingClausein classSqlValidatorImpl
-
validateOver
- Overrides:
validateOverin classSqlValidatorImpl
-
validateNamespace
Description copied from class:SqlValidatorImplValidates a namespace.- Overrides:
validateNamespacein classSqlValidatorImpl- Parameters:
namespace- NamespacetargetRowType- Desired row type, must not be null, may be the data type 'unknown'.
-
validateModality
Description copied from interface:SqlValidatorValidates that a query is capable of producing a return of given modality (relational or streaming).- Specified by:
validateModalityin interfaceSqlValidator- Overrides:
validateModalityin classSqlValidatorImpl- Parameters:
select- Querymodality- Modality (streaming or relational)fail- Whether to throw a user error if does not support required modality- Returns:
- whether query supports the given modality
-
shouldAllowOverRelation
protected boolean shouldAllowOverRelation()- Overrides:
shouldAllowOverRelationin classSqlValidatorImpl
-