public class SqlAdvisorValidator extends SqlValidatorImpl
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.SqlValidatorImpl.DmlNamespace, SqlValidatorImpl.FunctionParamInfo, SqlValidatorImpl.IdInfo, SqlValidatorImpl.Status
Modifier and Type | Field and Description |
---|---|
private java.util.Set<SqlValidatorNamespace> |
activeNamespaces |
private RelDataType |
emptyStructType |
expandColumnReferences, expandIdentifiers, functionCallStack, idPositions, namespaces, scopes, TRACER, typeFactory, unknownType, UPDATE_ANON_PREFIX, UPDATE_SRC_ALIAS, UPDATE_TGT_ALIAS
Constructor and Description |
---|
SqlAdvisorValidator(SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory,
SqlConformance conformance)
Creates a SqlAdvisor validator.
|
Modifier and Type | Method and Description |
---|---|
RelDataType |
deriveType(SqlValidatorScope scope,
SqlNode operand)
Calls the parent class method and mask Farrago exception thrown.
|
SqlNode |
expand(SqlNode expr,
SqlValidatorScope scope)
Expands an expression.
|
SqlNode |
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.
|
private void |
registerId(SqlIdentifier id,
SqlValidatorScope scope) |
protected boolean |
shouldAllowOverRelation() |
protected void |
validateFrom(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 void |
validateHavingClause(SqlSelect select)
Calls the parent class method and masks Farrago exception thrown.
|
void |
validateIdentifier(SqlIdentifier id,
SqlValidatorScope scope)
Registers the identifier and its scope into a map keyed by ParserPosition.
|
boolean |
validateModality(SqlSelect select,
SqlModality modality,
boolean fail)
Validates that a query is capable of producing a return of given modality
(relational or streaming).
|
protected void |
validateNamespace(SqlValidatorNamespace namespace,
RelDataType targetRowType)
Validates a namespace.
|
protected void |
validateOver(SqlCall call,
SqlValidatorScope scope) |
protected void |
validateWhereClause(SqlSelect select)
Calls the parent class method and masks Farrago exception thrown.
|
addToSelectList, checkTypeAssignment, createMatchRecognizeNameSpace, createSelectNamespace, createSetopNamespace, createSourceSelectForDelete, createSourceSelectForUpdate, createTargetRowType, declareCursor, deriveAlias, deriveConstructorType, expandGroupByOrHavingExpr, expandStar, getAggregate, getCatalogReader, getColumnReferenceExpansion, getConformance, getCursorScope, getDefaultNullCollation, getEmptyScope, getFieldOrigins, getFromScope, getGroupScope, getHavingScope, getJoinScope, getLogicalSourceRowType, getLogicalTargetRowType, getMatchRecognizeScope, getNamespace, getOperatorTable, getOrderScope, getOriginal, getOverScope, getParameterRowType, getParentCursor, getRawSelectScope, getSelectScope, getSelfJoinExprForUpdate, getTypeFactory, getUnknownType, getValidatedNodeType, getValidatedNodeTypeIfKnown, getValidationErrorFunction, getWhereScope, getWindowByName, getWithScope, handleUnresolvedFunction, inferUnknownTypes, isAggregate, isAggregate, isNestedAggregateWindow, isOverAggregateWindow, isSystemField, lookupHints, lookupNameCompletionHints, lookupQualifiedName, makeNullaryCall, newValidationError, performUnconditionalRewrites, popFunctionCall, pushFunctionCall, registerNamespace, removeValidatedNodeType, resolveWindow, setCallRewrite, setColumnReferenceExpansion, setDefaultNullCollation, setIdentifierExpansion, setOriginal, setValidatedNodeType, shouldAllowIntermediateOrderBy, shouldExpandIdentifiers, validate, validateAggregateParams, validateCall, validateColumnListParams, validateDataType, validateDelete, validateDynamicParam, validateFeature, validateGroupClause, validateInsert, validateIntervalQualifier, validateJoin, validateLiteral, validateMatchRecognize, validateMerge, validateOrderList, validateParameterizedExpression, validateQuery, validateSelect, validateSelectList, validateSequenceValue, validateUnnest, validateUpdate, validateValues, validateWhereOrOn, validateWindow, validateWindowClause, validateWith, validateWithItem
private final java.util.Set<SqlValidatorNamespace> activeNamespaces
private final RelDataType emptyStructType
public SqlAdvisorValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlConformance conformance)
opTab
- Operator tablecatalogReader
- Catalog readertypeFactory
- Type factoryconformance
- Compatibility modepublic void validateIdentifier(SqlIdentifier id, SqlValidatorScope scope)
validateIdentifier
in interface SqlValidator
validateIdentifier
in class SqlValidatorImpl
id
- Identifierscope
- Naming scopeprivate void registerId(SqlIdentifier id, SqlValidatorScope scope)
public SqlNode expand(SqlNode expr, SqlValidatorScope scope)
SqlValidator
expand
in interface SqlValidator
expand
in class SqlValidatorImpl
expr
- Expressionscope
- Scopepublic SqlNode expandOrderExpr(SqlSelect select, SqlNode orderExpr)
SqlValidator
This is made necessary by a couple of dialect 'features':
expandOrderExpr
in interface SqlValidator
expandOrderExpr
in class SqlValidatorImpl
select
- Select statement which contains ORDER BYorderExpr
- Expression in the ORDER BY clause.public RelDataType deriveType(SqlValidatorScope scope, SqlNode operand)
deriveType
in interface SqlValidator
deriveType
in class SqlValidatorImpl
scope
- Syntactic scopeoperand
- Parse tree nodeNULL
protected void validateFrom(SqlNode node, RelDataType targetRowType, SqlValidatorScope scope)
SqlValidatorImpl
validateFrom
in class SqlValidatorImpl
node
- Node in FROM clause, typically a table or derived
tabletargetRowType
- Desired row type of this expression, or
SqlValidatorImpl.unknownType
if not fussy. Must not be null.scope
- Scopeprotected void validateWhereClause(SqlSelect select)
validateWhereClause
in class SqlValidatorImpl
protected void validateHavingClause(SqlSelect select)
validateHavingClause
in class SqlValidatorImpl
protected void validateOver(SqlCall call, SqlValidatorScope scope)
validateOver
in class SqlValidatorImpl
protected void validateNamespace(SqlValidatorNamespace namespace, RelDataType targetRowType)
SqlValidatorImpl
validateNamespace
in class SqlValidatorImpl
namespace
- NamespacetargetRowType
- Desired row type, must not be null, may be the data
type 'unknown'.public boolean validateModality(SqlSelect select, SqlModality modality, boolean fail)
SqlValidator
validateModality
in interface SqlValidator
validateModality
in class SqlValidatorImpl
select
- Querymodality
- Modality (streaming or relational)fail
- Whether to throw a user error if does not support required
modalityprotected boolean shouldAllowOverRelation()
shouldAllowOverRelation
in class SqlValidatorImpl
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.