org.eigenbase.sql.advise
Class SqlAdvisorValidator

java.lang.Object
  extended by org.eigenbase.sql.validate.SqlValidatorImpl
      extended by org.eigenbase.sql.advise.SqlAdvisorValidator
All Implemented Interfaces:
SqlValidator, SqlValidatorWithHints

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.

Since:
Jan 16, 2005
Version:
$Id: //open/dev/farrago/src/org/eigenbase/sql/advise/SqlAdvisorValidator.java#7 $
Author:
tleung

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eigenbase.sql.validate.SqlValidatorImpl
SqlValidatorImpl.DmlNamespace, SqlValidatorImpl.FunctionParamInfo, SqlValidatorImpl.IdInfo, SqlValidatorImpl.Status
 
Nested classes/interfaces inherited from interface org.eigenbase.sql.validate.SqlValidator
SqlValidator.Compatible
 
Field Summary
private  Set<SqlValidatorNamespace> activeNamespaces
           
private  RelDataType emptyStructType
           
 
Fields inherited from class org.eigenbase.sql.validate.SqlValidatorImpl
expandColumnReferences, expandIdentifiers, functionCallStack, idPositions, namespaces, scopes, tracer, typeFactory, unknownType, UPDATE_ANON_PREFIX, UPDATE_SRC_ALIAS, UPDATE_TGT_ALIAS
 
Constructor Summary
SqlAdvisorValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlConformance conformance)
          Creates a SqlAdvisor validator.
 
Method Summary
 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 subquery.
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 ParserPostion.
protected  void validateNamespace(SqlValidatorNamespace namespace)
          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.
 
Methods inherited from class org.eigenbase.sql.validate.SqlValidatorImpl
addToSelectList, checkTypeAssignment, createSelectNamespace, createSetopNamespace, createSourceSelectForDelete, createSourceSelectForUpdate, createTargetRowType, declareCursor, deriveAlias, deriveConstructorType, expandStar, getCatalogReader, getConformance, getCursorScope, getFromScope, getGroupScope, getHavingScope, getJoinScope, getLogicalSourceRowType, getLogicalTargetRowType, getNamespace, getOperatorTable, getOrderScope, getOriginal, getOverScope, getParentCursor, getRawSelectScope, getScope, getSelectScope, getSelfJoinExprForUpdate, getTypeFactory, getUnknownType, getValidatedNodeType, getValidatedNodeTypeIfKnown, getWhereScope, getWindowByName, handleUnresolvedFunction, inferUnknownTypes, isAggregate, isAggregate, isSystemField, lookupHints, lookupNameCompletionHints, lookupQualifiedName, newValidationError, performUnconditionalRewrites, popFunctionCall, pushFunctionCall, registerNamespace, removeValidatedNodeType, resolveWindow, setCallRewrite, setColumnReferenceExpansion, setIdentifierExpansion, setOriginal, setValidatedNodeType, shouldAllowIntermediateOrderBy, shouldExpandIdentifiers, validate, validateAggregateParams, validateCall, validateColumnListParams, validateDataType, validateDelete, validateDynamicParam, validateFeature, validateGroupClause, validateInsert, validateIntervalQualifier, validateJoin, validateLiteral, validateMerge, validateOrderList, validateParameterizedExpression, validateQuery, validateSelect, validateSelectList, validateUpdate, validateValues, validateWhereOrOn, validateWindow, validateWindowClause
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeNamespaces

private final Set<SqlValidatorNamespace> activeNamespaces

emptyStructType

private final RelDataType emptyStructType
Constructor Detail

SqlAdvisorValidator

public SqlAdvisorValidator(SqlOperatorTable opTab,
                           SqlValidatorCatalogReader catalogReader,
                           RelDataTypeFactory typeFactory,
                           SqlConformance conformance)
Creates a SqlAdvisor validator.

Parameters:
opTab - Operator table
catalogReader - Catalog reader
typeFactory - Type factory
conformance - Compatibility mode
"Precondition:"
opTab != null, // node is a "query expression" (per SQL standard), catalogReader != null, typeFactory != null
Method Detail

validateIdentifier

public void validateIdentifier(SqlIdentifier id,
                               SqlValidatorScope scope)
Registers the identifier and its scope into a map keyed by ParserPostion.

Specified by:
validateIdentifier in interface SqlValidator
Overrides:
validateIdentifier in class SqlValidatorImpl
Parameters:
id - Identifier
scope - Naming scope

registerId

private void registerId(SqlIdentifier id,
                        SqlValidatorScope scope)

expand

public SqlNode expand(SqlNode expr,
                      SqlValidatorScope scope)
Description copied from interface: SqlValidator
Expands an expression.

Specified by:
expand in interface SqlValidator
Overrides:
expand in class SqlValidatorImpl
Parameters:
expr - Expression
scope - Scope
Returns:
Expanded expression

expandOrderExpr

public SqlNode expandOrderExpr(SqlSelect select,
                               SqlNode orderExpr)
Description copied from interface: SqlValidator
Expands 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':

Specified by:
expandOrderExpr in interface SqlValidator
Overrides:
expandOrderExpr in class SqlValidatorImpl
Parameters:
select - Select statement which contains ORDER BY
orderExpr - Expression in the ORDER BY clause.
Returns:
Expression translated into SELECT clause semantics

deriveType

public RelDataType deriveType(SqlValidatorScope scope,
                              SqlNode operand)
Calls the parent class method and mask Farrago exception thrown.

Specified by:
deriveType in interface SqlValidator
Overrides:
deriveType in class SqlValidatorImpl
Parameters:
scope - Syntactic scope
operand - Parse tree node
Returns:
Type of the SqlNode. Should never return NULL

validateFrom

protected void validateFrom(SqlNode node,
                            RelDataType targetRowType,
                            SqlValidatorScope scope)
Description copied from class: SqlValidatorImpl
Validates the FROM clause of a query, or (recursively) a child node of the FROM clause: AS, OVER, JOIN, VALUES, or subquery.

Overrides:
validateFrom in class SqlValidatorImpl
Parameters:
node - Node in FROM clause, typically a table or derived table
targetRowType - Desired row type of this expression, or SqlValidatorImpl.unknownType if not fussy. Must not be null.
scope - Scope

validateWhereClause

protected void validateWhereClause(SqlSelect select)
Calls the parent class method and masks Farrago exception thrown.

Overrides:
validateWhereClause in class SqlValidatorImpl

validateHavingClause

protected void validateHavingClause(SqlSelect select)
Calls the parent class method and masks Farrago exception thrown.

Overrides:
validateHavingClause in class SqlValidatorImpl

validateOver

protected void validateOver(SqlCall call,
                            SqlValidatorScope scope)
Overrides:
validateOver in class SqlValidatorImpl

validateNamespace

protected void validateNamespace(SqlValidatorNamespace namespace)
Description copied from class: SqlValidatorImpl
Validates a namespace.

Overrides:
validateNamespace in class SqlValidatorImpl

shouldAllowOverRelation

protected boolean shouldAllowOverRelation()
Overrides:
shouldAllowOverRelation in class SqlValidatorImpl