com.lucidera.farrago
Class LucidDbSqlValidator

java.lang.Object
  extended by org.eigenbase.sql.validate.SqlValidatorImpl
      extended by net.sf.farrago.query.FarragoSqlValidator
          extended by com.lucidera.farrago.LucidDbSqlValidator
All Implemented Interfaces:
SqlValidator, SqlValidatorWithHints

public class LucidDbSqlValidator
extends FarragoSqlValidator

LucidDbSqlValidator refines FarragoSqlValidator with LucidDB-specifics.

Version:
$Id: //open/dev/farrago/src/com/lucidera/farrago/LucidDbSqlValidator.java#11 $
Author:
Zelaine Fong

Nested Class Summary
private  class LucidDbSqlValidator.EquiJoinFinder
          Visitor that walks a SqlNode expression tree looking for an equijoin between a source and target column.
 
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
 
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
LucidDbSqlValidator(FarragoPreparingStmt preparingStmt, SqlConformance conformance)
           
LucidDbSqlValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlConformance conformance, FarragoPreparingStmt preparingStmt)
           
 
Method Summary
protected  SqlNode getSelfJoinExprForUpdate(SqlIdentifier table, String alias)
          Allows a subclass to provide information about how to convert an UPDATE into a MERGE via self-join.
private  boolean inFailFastMode()
           
 void validateMerge(SqlMerge call)
          Validates a MERGE statement.
private  void validateMergeUniqueKeys(SqlMerge call)
          Validates the merge statement for updates on unique key columns
private  boolean validateUniqueColumn(SqlNode sourceExpr, SqlNode onCondition, SqlIdentifier targetCol, SqlValidatorScope scope)
          Validates a unique column to ensure that either it isn't being updated, or if it's being updated, the update is a no-op because the column is either being set to itself or the column it is being equi-joined with in the ON clause of the MERGE statement
 
Methods inherited from class net.sf.farrago.query.FarragoSqlValidator
getPreparingStmt, shouldAllowIntermediateOrderBy, shouldExpandIdentifiers, validate, validateColumnListParams, validateDataType, validateDelete, validateFeature, validateInsert, validateUpdate
 
Methods inherited from class org.eigenbase.sql.validate.SqlValidatorImpl
addToSelectList, checkTypeAssignment, createSelectNamespace, createSetopNamespace, createSourceSelectForDelete, createSourceSelectForUpdate, createTargetRowType, declareCursor, deriveAlias, deriveConstructorType, deriveType, expand, expandOrderExpr, expandStar, getCatalogReader, getConformance, getCursorScope, getFromScope, getGroupScope, getHavingScope, getJoinScope, getLogicalSourceRowType, getLogicalTargetRowType, getNamespace, getOperatorTable, getOrderScope, getOriginal, getOverScope, getParentCursor, getRawSelectScope, getScope, getSelectScope, 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, shouldAllowOverRelation, validateAggregateParams, validateCall, validateDynamicParam, validateFrom, validateGroupClause, validateHavingClause, validateIdentifier, validateIntervalQualifier, validateJoin, validateLiteral, validateNamespace, validateOrderList, validateOver, validateParameterizedExpression, validateQuery, validateSelect, validateSelectList, validateValues, validateWhereClause, validateWhereOrOn, validateWindow, validateWindowClause
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LucidDbSqlValidator

public LucidDbSqlValidator(SqlOperatorTable opTab,
                           SqlValidatorCatalogReader catalogReader,
                           RelDataTypeFactory typeFactory,
                           SqlConformance conformance,
                           FarragoPreparingStmt preparingStmt)

LucidDbSqlValidator

public LucidDbSqlValidator(FarragoPreparingStmt preparingStmt,
                           SqlConformance conformance)
Method Detail

validateMerge

public void validateMerge(SqlMerge call)
Description copied from interface: SqlValidator
Validates a MERGE statement.

Specified by:
validateMerge in interface SqlValidator
Overrides:
validateMerge in class FarragoSqlValidator
Parameters:
call - MERGE statement

validateMergeUniqueKeys

private void validateMergeUniqueKeys(SqlMerge call)
Validates the merge statement for updates on unique key columns

Parameters:
call - merge statement

validateUniqueColumn

private boolean validateUniqueColumn(SqlNode sourceExpr,
                                     SqlNode onCondition,
                                     SqlIdentifier targetCol,
                                     SqlValidatorScope scope)
Validates a unique column to ensure that either it isn't being updated, or if it's being updated, the update is a no-op because the column is either being set to itself or the column it is being equi-joined with in the ON clause of the MERGE statement

Parameters:
sourceExpr - expression that the column is being updated with
onCondition - ON condition of the MERGE statement
targetCol - target column being updated
scope - scope of the body of the statement
Returns:
true if the unique column is not updated or is updated to a value that does not change the column value

inFailFastMode

private boolean inFailFastMode()

getSelfJoinExprForUpdate

protected SqlNode getSelfJoinExprForUpdate(SqlIdentifier table,
                                           String alias)
Description copied from class: SqlValidatorImpl
Allows a subclass to provide information about how to convert an UPDATE into a MERGE via self-join. If this method returns null, then no such conversion takes place. Otherwise, this method should return a suitable unique identifier expression for the given table.

Overrides:
getSelfJoinExprForUpdate in class SqlValidatorImpl
Parameters:
table - identifier for table being updated
alias - alias to use for qualifying columns in expression, or null for unqualified references; if this is equal to "SYS$SRC", then column references have been anonymized to "SYS$ANONx", where x is the 1-based column number.
Returns:
expression for unique identifier, or null to prevent conversion