public class SqlValidatorImpl extends Object implements SqlValidatorWithHints
SqlValidator.| Modifier and Type | Class and Description |
|---|---|
private static class |
SqlValidatorImpl.DeleteNamespace
Namespace for a DELETE statement.
|
private class |
SqlValidatorImpl.DeriveTypeVisitor
Visitor which derives the type of a given
SqlNode. |
static class |
SqlValidatorImpl.DmlNamespace
Common base class for DML statement namespaces.
|
private static class |
SqlValidatorImpl.Expander
Converts an expression into canonical form by fully-qualifying any
identifiers.
|
(package private) static class |
SqlValidatorImpl.ExtendedExpander
Shuttle which walks over an expression in the GROUP BY/HAVING clause, replacing
usages of aliases or ordinals with the underlying expression.
|
protected static class |
SqlValidatorImpl.FunctionParamInfo
Utility object used to maintain information about the parameters in a
function call.
|
protected static class |
SqlValidatorImpl.IdInfo
Information about an identifier in a particular scope.
|
private static class |
SqlValidatorImpl.InsertNamespace
Namespace for an INSERT statement.
|
private static class |
SqlValidatorImpl.MergeNamespace
Namespace for a MERGE statement.
|
private static class |
SqlValidatorImpl.NavigationExpander
Shuttle that expands navigation expressions in a MATCH_RECOGNIZE clause.
|
private static class |
SqlValidatorImpl.NavigationModifier
Modify the nodes in navigation function
such as FIRST, LAST, PREV AND NEXT.
|
private static class |
SqlValidatorImpl.NavigationReplacer
Shuttle that replaces
A as A.price > PREV(B.price) with
PREV(A.price, 0) > LAST(B.price, 0). |
(package private) class |
SqlValidatorImpl.OrderExpressionExpander
Shuttle which walks over an expression in the ORDER BY clause, replacing
usages of aliases with the underlying expression.
|
private class |
SqlValidatorImpl.PatternValidator
Within one navigation function, the pattern var should be same
|
private class |
SqlValidatorImpl.PatternVarVisitor
retrieve pattern variables defined
|
static class |
SqlValidatorImpl.Status
Validation status.
|
private static class |
SqlValidatorImpl.UpdateNamespace
Namespace for an UPDATE statement.
|
private class |
SqlValidatorImpl.ValidationError
Throws a validator exception with access to the validator context.
|
(package private) class |
SqlValidatorImpl.ValidationErrorFunction
Throws a validator exception with access to the validator context.
|
| Modifier and Type | Field and Description |
|---|---|
private AggFinder |
aggFinder |
private AggFinder |
aggOrOverFinder |
private AggFinder |
aggOrOverOrGroupFinder |
private RelDataType |
booleanType |
(package private) SqlValidatorCatalogReader |
catalogReader |
private SqlConformance |
conformance |
private Map<SqlSelect,SqlValidatorScope> |
cursorScopes
Maps a
SqlSelect node that is the argument to a CURSOR
constructor to the scope of the result of that select node |
private Set<SqlNode> |
cursorSet
Set of select expressions used as cursor definitions.
|
protected boolean |
expandColumnReferences |
protected boolean |
expandIdentifiers |
protected Deque<SqlValidatorImpl.FunctionParamInfo> |
functionCallStack
Stack of objects that maintain information about function calls.
|
private Map<SqlSelect,SqlValidatorScope> |
groupByScopes
Maps a
SqlSelect node to the scope used by its GROUP BY clause. |
private AggFinder |
groupFinder |
protected Map<String,SqlValidatorImpl.IdInfo> |
idPositions
Maps ParsePosition strings to the
SqlIdentifier identifier
objects at these positions |
private boolean |
inWindow |
protected Map<SqlNode,SqlValidatorNamespace> |
namespaces
|
private int |
nextGeneratedId |
private Map<SqlNode,RelDataType> |
nodeToTypeMap
Map of derived RelDataType for each node.
|
private NullCollation |
nullCollation |
private SqlOperatorTable |
opTab |
private Map<SqlSelect,SqlValidatorScope> |
orderScopes
Maps a
SqlSelect node to the scope used by its ORDER BY clause. |
private Map<SqlNode,SqlNode> |
originalExprs |
private AggFinder |
overFinder |
private boolean |
rewriteCalls |
protected Map<SqlNode,SqlValidatorScope> |
scopes
Maps
query node objects to the SqlValidatorScope
scope created from them. |
private Map<SqlSelect,SqlValidatorScope> |
selectScopes
Maps a
SqlSelect node to the scope used by its SELECT and HAVING
clauses. |
private TableScope |
tableScope
The name-resolution scope of a LATERAL TABLE clause.
|
private SqlNode |
top |
static org.slf4j.Logger |
TRACER |
protected RelDataTypeFactory |
typeFactory |
protected RelDataType |
unknownType
The type of dynamic parameters until a type is imposed on them.
|
static String |
UPDATE_ANON_PREFIX
Alias prefix generated for source columns when rewriting UPDATE to MERGE.
|
static String |
UPDATE_SRC_ALIAS
Alias generated for the source table when rewriting UPDATE to MERGE.
|
static String |
UPDATE_TGT_ALIAS
Alias generated for the target table when rewriting UPDATE to MERGE if no
alias was specified by the user.
|
private boolean |
validatingSqlMerge |
private SqlValidatorImpl.ValidationErrorFunction |
validationErrorFunction |
private Map<SqlSelect,SqlValidatorScope> |
whereScopes
Maps a
SqlSelect node to the scope used by its WHERE and HAVING
clauses. |
STRICT| Modifier | Constructor and Description |
|---|---|
protected |
SqlValidatorImpl(SqlOperatorTable opTab,
SqlValidatorCatalogReader catalogReader,
RelDataTypeFactory typeFactory,
SqlConformance conformance)
Creates a validator.
|
| Modifier and Type | Method and Description |
|---|---|
private boolean |
addOrExpandField(List<SqlNode> selectItems,
Set<String> aliases,
List<Map.Entry<String,RelDataType>> types,
boolean includeSystemVars,
SelectScope scope,
SqlIdentifier id,
RelDataTypeField field) |
protected void |
addToSelectList(List<SqlNode> list,
Set<String> aliases,
List<Map.Entry<String,RelDataType>> fieldList,
SqlNode exp,
SqlValidatorScope scope,
boolean includeSystemVars)
Adds an expression to a select list, ensuring that its alias does not
clash with any existing expressions on the list.
|
private static String |
alias(SqlNode item)
Returns the alias of a "expr AS alias" expression.
|
private void |
checkConstraint(SqlValidatorTable validatorTable,
SqlNode source,
RelDataType targetRowType)
Validates insert values against the constraint of a modifiable view.
|
private void |
checkConstraint(SqlValidatorTable validatorTable,
SqlUpdate update,
RelDataType targetRowType)
Validates updates against the constraint of a modifiable view.
|
private void |
checkFieldCount(SqlNode node,
SqlValidatorTable table,
SqlNode source,
RelDataType logicalSourceRowType,
RelDataType logicalTargetRowType) |
private void |
checkRollUp(SqlNode grandParent,
SqlNode parent,
SqlNode current,
SqlValidatorScope scope) |
private void |
checkRollUp(SqlNode grandParent,
SqlNode parent,
SqlNode current,
SqlValidatorScope scope,
String optionalClause) |
private void |
checkRollUpInGroupBy(SqlSelect select) |
private void |
checkRollUpInOrderBy(SqlSelect select) |
private void |
checkRollUpInSelectList(SqlSelect select) |
private void |
checkRollUpInUsing(SqlIdentifier identifier,
SqlNode leftOrRight) |
private void |
checkRollUpInWindow(SqlWindow window,
SqlValidatorScope scope) |
private void |
checkRollUpInWindowDecl(SqlSelect select) |
protected void |
checkTypeAssignment(RelDataType sourceRowType,
RelDataType targetRowType,
SqlNode query) |
protected MatchRecognizeNamespace |
createMatchRecognizeNameSpace(SqlMatchRecognize call,
SqlNode enclosingNode) |
protected SelectNamespace |
createSelectNamespace(SqlSelect select,
SqlNode enclosingNode)
Creates a namespace for a
SELECT node. |
protected SetopNamespace |
createSetopNamespace(SqlCall call,
SqlNode enclosingNode)
Creates a namespace for a set operation (
UNION,
INTERSECT, or EXCEPT). |
protected SqlSelect |
createSourceSelectForDelete(SqlDelete call)
Creates the SELECT statement that putatively feeds rows into a DELETE
statement to be deleted.
|
protected SqlSelect |
createSourceSelectForUpdate(SqlUpdate call)
Creates the SELECT statement that putatively feeds rows into an UPDATE
statement to be updated.
|
protected RelDataType |
createTargetRowType(SqlValidatorTable table,
SqlNodeList targetColumnList,
boolean append)
Derives a row-type for INSERT and UPDATE operations.
|
void |
declareCursor(SqlSelect select,
SqlValidatorScope parentScope)
Declares a SELECT expression as a cursor.
|
private SqlModality |
deduceModality(SqlNode query)
Return the intended modality of a SELECT or set-op.
|
String |
deriveAlias(SqlNode node,
int ordinal)
Derives an alias for an expression.
|
RelDataType |
deriveConstructorType(SqlValidatorScope scope,
SqlCall call,
SqlFunction unresolvedConstructor,
SqlFunction resolvedConstructor,
List<RelDataType> argTypes)
Derives the type of a constructor.
|
RelDataType |
deriveType(SqlValidatorScope scope,
SqlNode expr)
Derives the type of a node in a given scope.
|
(package private) RelDataType |
deriveTypeImpl(SqlValidatorScope scope,
SqlNode operand)
Derives the type of a node, never null.
|
SqlNode |
expand(SqlNode expr,
SqlValidatorScope scope)
Expands an expression.
|
SqlNode |
expandGroupByOrHavingExpr(SqlNode expr,
SqlValidatorScope scope,
SqlSelect select,
boolean havingExpression) |
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 boolean |
expandSelectItem(SqlNode selectItem,
SqlSelect select,
RelDataType targetType,
List<SqlNode> selectItems,
Set<String> aliases,
List<Map.Entry<String,RelDataType>> types,
boolean includeSystemVars)
If
selectItem is "*" or "TABLE.*", expands it and returns
true; otherwise writes the unexpanded item. |
private boolean |
expandStar(List<SqlNode> selectItems,
Set<String> aliases,
List<Map.Entry<String,RelDataType>> types,
boolean includeSystemVars,
SelectScope scope,
SqlNode node) |
SqlNodeList |
expandStar(SqlNodeList selectList,
SqlSelect select,
boolean includeSystemVars)
Returns a list of expressions, with every occurrence of "*" or
"TABLE.*" expanded.
|
private static void |
findAllValidFunctionNames(List<String> names,
SqlValidator validator,
Collection<SqlMoniker> result,
SqlParserPos pos) |
private static void |
findAllValidUdfNames(List<String> names,
SqlValidator validator,
Collection<SqlMoniker> result) |
private Table |
findTable(CalciteSchema schema,
String tableName,
boolean caseSensitive) |
private Table |
findTable(String alias)
Given a table alias, find the corresponding
Table associated with it |
private Pair<String,String> |
findTableColumnPair(SqlIdentifier identifier,
SqlValidatorScope scope) |
private SqlNode |
getAgg(SqlSelect select)
If there is at least one call to an aggregate function, returns the
first.
|
protected SqlNode |
getAggregate(SqlSelect select)
Returns the parse tree node (GROUP BY, HAVING, or an aggregate function
call) that causes
select to be an aggregate query, or null if it
is not an aggregate query. |
SqlValidatorCatalogReader |
getCatalogReader()
Returns the catalog reader used by this validator.
|
boolean |
getColumnReferenceExpansion() |
SqlConformance |
getConformance()
Returns the dialect of SQL (SQL:2003, etc.) this validator recognizes.
|
SqlValidatorScope |
getCursorScope(SqlSelect select) |
NullCollation |
getDefaultNullCollation()
Returns how NULL values should be collated if an ORDER BY item does not
contain NULLS FIRST or NULLS LAST.
|
SqlValidatorScope |
getEmptyScope() |
private List<String> |
getFieldOrigin(SqlNode sqlQuery,
int i) |
List<List<String>> |
getFieldOrigins(SqlNode sqlQuery)
Returns a description of how each field in the row type maps to a
catalog, schema, table and column in the schema.
|
SqlValidatorScope |
getFromScope(SqlSelect select)
Returns a scope containing the objects visible from the FROM clause of a
query.
|
SqlValidatorScope |
getGroupScope(SqlSelect select)
Returns a scope containing the objects visible from the GROUP BY clause
of a query.
|
SqlValidatorScope |
getHavingScope(SqlSelect select)
Returns a scope containing the objects visible from the HAVING clause of
a query.
|
private SqlSelect |
getInnerSelect(SqlNode node) |
SqlValidatorScope |
getJoinScope(SqlNode node)
Returns a scope containing the objects visible from the ON and USING
sections of a JOIN clause.
|
protected RelDataType |
getLogicalSourceRowType(RelDataType sourceRowType,
SqlInsert insert) |
protected RelDataType |
getLogicalTargetRowType(RelDataType targetRowType,
SqlInsert insert) |
SqlValidatorScope |
getMatchRecognizeScope(SqlMatchRecognize node)
Returns a scope match recognize clause.
|
private SqlValidatorNamespace |
getNamespace(SqlIdentifier id,
DelegatingScope scope) |
SqlValidatorNamespace |
getNamespace(SqlNode node)
Finds the namespace corresponding to a given node.
|
private SqlValidatorNamespace |
getNamespace(SqlNode node,
SqlValidatorScope scope) |
private SqlNode |
getNthExpr(SqlNode query,
int ordinal,
int sourceCount)
Locates the n'th expression in an INSERT or UPDATE query.
|
SqlOperatorTable |
getOperatorTable()
Returns the operator table used by this validator.
|
SqlValidatorScope |
getOrderScope(SqlSelect select)
Returns the scope that expressions in the SELECT and HAVING clause of
this query should use.
|
SqlNode |
getOriginal(SqlNode expr) |
SqlValidatorScope |
getOverScope(SqlNode node)
Returns the scope of an OVER or VALUES node.
|
RelDataType |
getParameterRowType(SqlNode sqlQuery)
Returns a record type that contains the name and type of each parameter.
|
String |
getParentCursor(String columnListParamName)
Retrieves the name of the parent cursor referenced by a column list
parameter.
|
SelectScope |
getRawSelectScope(SqlSelect select)
Returns the scope for resolving the SELECT, GROUP BY and HAVING clauses.
|
SqlValidatorScope |
getSelectScope(SqlSelect select)
Returns the appropriate scope for validating a particular clause of a
SELECT statement.
|
protected SqlNode |
getSelfJoinExprForUpdate(SqlNode table,
String alias)
Allows a subclass to provide information about how to convert an UPDATE
into a MERGE via self-join.
|
(package private) RelDataType |
getTableConstructorRowType(SqlCall values,
SqlValidatorScope scope)
Returns null if there is no common type.
|
RelDataTypeFactory |
getTypeFactory()
Returns the type factory used by this validator.
|
RelDataType |
getUnknownType()
Returns an object representing the "unknown" type.
|
RelDataType |
getValidatedNodeType(SqlNode node)
Returns the type assigned to a node by validation.
|
RelDataType |
getValidatedNodeTypeIfKnown(SqlNode node)
Returns the type assigned to a node by validation, or null if unknown.
|
SqlValidatorImpl.ValidationErrorFunction |
getValidationErrorFunction() |
SqlValidatorScope |
getWhereScope(SqlSelect select)
Returns the scope that expressions in the WHERE and GROUP BY clause of
this query should use.
|
protected SqlWindow |
getWindowByName(SqlIdentifier id,
SqlValidatorScope scope) |
private SqlWindow |
getWindowInOver(SqlNode over) |
SqlValidatorScope |
getWithScope(SqlNode withItem) |
private void |
handleOffsetFetch(SqlNode offset,
SqlNode fetch) |
private void |
handleScalarSubQuery(SqlSelect parentSelect,
SqlSelect selectItem,
List<SqlNode> expandedSelectItems,
Set<String> aliasList,
List<Map.Entry<String,RelDataType>> fieldList)
Processes SubQuery found in Select list.
|
CalciteException |
handleUnresolvedFunction(SqlCall call,
SqlFunction unresolvedFunction,
List<RelDataType> argTypes,
List<String> argNames)
Handles a call to a function which cannot be resolved.
|
private boolean |
hasSortedPrefix(SelectScope scope,
SqlNodeList orderList)
Returns whether the prefix is sorted.
|
protected void |
inferUnknownTypes(RelDataType inferredType,
SqlValidatorScope scope,
SqlNode node) |
boolean |
isAggregate(SqlNode selectNode)
Returns whether a select list expression is an aggregate function.
|
boolean |
isAggregate(SqlSelect select)
Returns whether a SELECT statement is an aggregation.
|
private static boolean |
isAggregation(SqlKind kind) |
private static boolean |
isLateral(SqlNode node) |
private static boolean |
isLogicalNavigation(SqlKind kind) |
protected boolean |
isNestedAggregateWindow(SqlNode node) |
protected boolean |
isOverAggregateWindow(SqlNode node) |
private static boolean |
isPhysicalNavigation(SqlKind kind) |
private boolean |
isRolledUpColumn(SqlIdentifier identifier,
SqlValidatorScope scope) |
private boolean |
isRolledUpColumnAllowedInAgg(SqlIdentifier identifier,
SqlValidatorScope scope,
SqlCall aggCall,
SqlNode parent) |
private boolean |
isRowWithDefault(SqlNode operand,
int column) |
private static boolean |
isRunningOrFinal(SqlKind kind) |
private static boolean |
isSingleVarRequired(SqlKind kind) |
private boolean |
isSortCompatible(SelectScope scope,
SqlNode node,
boolean descending) |
boolean |
isSystemField(RelDataTypeField field)
Returns whether a field is a system field.
|
private boolean |
isValuesWithDefault(SqlNode source,
int column)
Returns whether a query uses
DEFAULT to populate a given
column. |
(package private) SqlValidatorNamespace |
lookupFieldNamespace(RelDataType rowType,
String name) |
private void |
lookupFromHints(SqlNode node,
SqlValidatorScope scope,
SqlParserPos pos,
Collection<SqlMoniker> hintList) |
List<SqlMoniker> |
lookupHints(SqlNode topNode,
SqlParserPos pos)
Looks up completion hints for a syntactically correct SQL statement that
has been parsed into an expression tree.
|
private void |
lookupJoinHints(SqlJoin join,
SqlValidatorScope scope,
SqlParserPos pos,
Collection<SqlMoniker> hintList) |
void |
lookupNameCompletionHints(SqlValidatorScope scope,
List<String> names,
SqlParserPos pos,
Collection<SqlMoniker> hintList)
Populates a list of all the valid alternatives for an identifier.
|
SqlMoniker |
lookupQualifiedName(SqlNode topNode,
SqlParserPos pos)
Looks up the fully qualified name for a
SqlIdentifier at a given
Parser Position in a parsed expression tree Note: call this only after
SqlValidator.validate(org.apache.calcite.sql.SqlNode) has been called. |
(package private) void |
lookupSelectHints(SqlSelect select,
SqlParserPos pos,
Collection<SqlMoniker> hintList)
Looks up completion hints for a syntactically correct select SQL that has
been parsed into an expression tree.
|
private void |
lookupSelectHints(SqlValidatorNamespace ns,
SqlParserPos pos,
Collection<SqlMoniker> hintList) |
private SqlNode |
navigationInDefine(SqlNode node,
String alpha)
Checks that all pattern variables within a function are the same,
and canonizes expressions such as
PREV(B.price) to
LAST(B.price, 0). |
private SqlNode |
navigationInMeasure(SqlNode node,
boolean allRows) |
CalciteContextException |
newValidationError(SqlNode node,
Resources.ExInst<SqlValidatorException> e)
Adds "line x, column y" context to a validator exception.
|
protected SqlNode |
performUnconditionalRewrites(SqlNode node,
boolean underFrom)
Performs expression rewrites which are always used unconditionally.
|
void |
popFunctionCall()
Removes the topmost entry from the function call stack.
|
void |
pushFunctionCall()
Pushes a new instance of a function call on to a function call stack.
|
private SqlNode |
registerFrom(SqlValidatorScope parentScope,
SqlValidatorScope usingScope,
SqlNode node,
SqlNode enclosingNode,
String alias,
SqlNodeList extendList,
boolean forceNullable)
Registers scopes and namespaces implied a relational expression in the
FROM clause.
|
private void |
registerMatchRecognize(SqlValidatorScope parentScope,
SqlValidatorScope usingScope,
SqlMatchRecognize call,
SqlNode enclosingNode,
String alias,
boolean forceNullable) |
protected void |
registerNamespace(SqlValidatorScope usingScope,
String alias,
SqlValidatorNamespace ns,
boolean forceNullable)
Registers a new namespace, and adds it as a child of its parent scope.
|
private void |
registerOperandSubQueries(SqlValidatorScope parentScope,
SqlCall call,
int operandOrdinal)
Registers any sub-queries inside a given call operand, and converts the
operand to a scalar sub-query if the operator requires it.
|
private void |
registerQuery(SqlValidatorScope parentScope,
SqlValidatorScope usingScope,
SqlNode node,
SqlNode enclosingNode,
String alias,
boolean forceNullable)
Registers a query in a parent scope.
|
private void |
registerQuery(SqlValidatorScope parentScope,
SqlValidatorScope usingScope,
SqlNode node,
SqlNode enclosingNode,
String alias,
boolean forceNullable,
boolean checkUpdate)
Registers a query in a parent scope.
|
private void |
registerSetop(SqlValidatorScope parentScope,
SqlValidatorScope usingScope,
SqlNode node,
SqlNode enclosingNode,
String alias,
boolean forceNullable) |
private void |
registerSubQueries(SqlValidatorScope parentScope,
SqlNode node) |
private void |
registerWith(SqlValidatorScope parentScope,
SqlValidatorScope usingScope,
SqlWith with,
SqlNode enclosingNode,
String alias,
boolean forceNullable,
boolean checkUpdate) |
void |
removeValidatedNodeType(SqlNode node)
Removes a node from the set of validated nodes
|
SqlWindow |
resolveWindow(SqlNode windowOrRef,
SqlValidatorScope scope,
boolean populateBounds)
Converts a window specification or window name into a fully-resolved
window specification.
|
private void |
rewriteMerge(SqlMerge call) |
private SqlNode |
rewriteUpdateToMerge(SqlUpdate updateCall,
SqlNode selfJoinSrcExpr) |
void |
setCallRewrite(boolean rewriteCalls)
Enables or disables rewrite of "macro-like" calls such as COALESCE.
|
void |
setColumnReferenceExpansion(boolean expandColumnReferences)
Enables or disables expansion of column references.
|
void |
setDefaultNullCollation(NullCollation nullCollation)
Sets how NULL values should be collated if an ORDER BY item does not
contain NULLS FIRST or NULLS LAST.
|
void |
setIdentifierExpansion(boolean expandIdentifiers)
Enables or disables expansion of identifiers other than column
references.
|
void |
setOriginal(SqlNode expr,
SqlNode original) |
void |
setValidatedNodeType(SqlNode node,
RelDataType type)
Saves the type of a
SqlNode, now that it has been validated. |
protected boolean |
shouldAllowIntermediateOrderBy() |
protected boolean |
shouldAllowOverRelation() |
private boolean |
shouldCheckForRollUp(SqlNode from) |
boolean |
shouldExpandIdentifiers()
Returns expansion of identifiers.
|
private SqlNode |
stripDot(SqlNode node) |
private static SqlNode |
stripOver(SqlNode node) |
SqlNode |
validate(SqlNode topNode)
Validates an expression tree.
|
private void |
validateAccess(SqlNode node,
SqlValidatorTable table,
SqlAccessEnum requiredAccess)
Validates access to a table.
|
void |
validateAggregateParams(SqlCall aggCall,
SqlNode filter,
SqlValidatorScope scope)
Validates parameters for aggregate function.
|
void |
validateCall(SqlCall call,
SqlValidatorScope scope)
Validates a call to an operator.
|
void |
validateColumnListParams(SqlFunction function,
List<RelDataType> argTypes,
List<SqlNode> operands)
Validates a COLUMN_LIST parameter
|
void |
validateDataType(SqlDataTypeSpec dataType)
Validates a data type expression.
|
private void |
validateDefinitions(SqlMatchRecognize mr,
MatchRecognizeScope scope) |
void |
validateDelete(SqlDelete call)
Validates a DELETE statement.
|
void |
validateDynamicParam(SqlDynamicParam dynamicParam)
Validates a dynamic parameter.
|
private void |
validateExpr(SqlNode expr,
SqlValidatorScope scope)
Validates an expression.
|
protected void |
validateFeature(Feature feature,
SqlParserPos context)
Validates that a particular feature is enabled.
|
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.
|
private void |
validateGroupByItem(SqlSelect select,
SqlNode groupByItem)
Validates an item in the GROUP BY clause of a SELECT statement.
|
protected void |
validateGroupClause(SqlSelect select)
Validates the GROUP BY clause of a SELECT statement.
|
private void |
validateGroupingSets(SqlValidatorScope groupScope,
AggregatingSelectScope aggregatingScope,
SqlCall groupItem) |
private void |
validateGroupItem(SqlValidatorScope groupScope,
AggregatingSelectScope aggregatingScope,
SqlNode groupItem) |
protected void |
validateHavingClause(SqlSelect select) |
void |
validateIdentifier(SqlIdentifier id,
SqlValidatorScope scope)
Resolves an identifier to a fully-qualified name.
|
void |
validateInsert(SqlInsert insert)
Validates an INSERT statement.
|
void |
validateIntervalQualifier(SqlIntervalQualifier qualifier)
Validates a
SqlIntervalQualifier |
protected void |
validateJoin(SqlJoin join,
SqlValidatorScope scope) |
void |
validateLiteral(SqlLiteral literal)
Validates a literal.
|
private void |
validateLiteralAsDouble(SqlLiteral literal) |
void |
validateMatchRecognize(SqlCall call)
Validates a MATCH_RECOGNIZE clause.
|
private List<Map.Entry<String,RelDataType>> |
validateMeasure(SqlMatchRecognize mr,
MatchRecognizeScope scope,
boolean allRows) |
void |
validateMerge(SqlMerge call)
Validates a MERGE statement.
|
private void |
validateModality(SqlNode query)
Validates that a query can deliver the modality it promises.
|
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.
|
private void |
validateNoAggs(AggFinder aggFinder,
SqlNode node,
String clause)
Throws an error if there is an aggregate or windowed aggregate in the
given clause.
|
private void |
validateNodeFeature(SqlNode node) |
private void |
validateOrderItem(SqlSelect select,
SqlNode orderItem)
Validates an item in the ORDER BY clause of a SELECT statement.
|
protected void |
validateOrderList(SqlSelect select)
Validates the ORDER BY clause of a SELECT statement.
|
protected void |
validateOver(SqlCall call,
SqlValidatorScope scope) |
SqlNode |
validateParameterizedExpression(SqlNode topNode,
Map<String,RelDataType> nameToTypeMap)
Validates an expression tree.
|
void |
validateQuery(SqlNode node,
SqlValidatorScope scope,
RelDataType targetRowType)
Checks that a query is valid.
|
private SqlNode |
validateScopedExpression(SqlNode topNode,
SqlValidatorScope scope) |
protected void |
validateSelect(SqlSelect select,
RelDataType targetRowType)
Validates a SELECT statement.
|
protected RelDataType |
validateSelectList(SqlNodeList selectItems,
SqlSelect select,
RelDataType targetRowType) |
void |
validateSequenceValue(SqlValidatorScope scope,
SqlIdentifier id) |
void |
validateUpdate(SqlUpdate call)
Validates an UPDATE statement.
|
private RelDataType |
validateUsingCol(SqlIdentifier id,
SqlNode leftOrRight) |
protected void |
validateValues(SqlCall node,
RelDataType targetRowType,
SqlValidatorScope scope)
Validates a VALUES clause.
|
protected void |
validateWhereClause(SqlSelect select) |
protected void |
validateWhereOrOn(SqlValidatorScope scope,
SqlNode condition,
String clause) |
void |
validateWindow(SqlNode windowOrId,
SqlValidatorScope scope,
SqlCall call)
Validates the right-hand side of an OVER expression.
|
protected void |
validateWindowClause(SqlSelect select) |
void |
validateWith(SqlWith with,
SqlValidatorScope scope) |
void |
validateWithItem(SqlWithItem withItem) |
public static final org.slf4j.Logger TRACER
public static final String UPDATE_SRC_ALIAS
public static final String UPDATE_TGT_ALIAS
public static final String UPDATE_ANON_PREFIX
private final SqlOperatorTable opTab
final SqlValidatorCatalogReader catalogReader
protected final Map<String,SqlValidatorImpl.IdInfo> idPositions
SqlIdentifier identifier
objects at these positionsprotected final Map<SqlNode,SqlValidatorScope> scopes
query node objects to the SqlValidatorScope
scope created from them.private final Map<SqlSelect,SqlValidatorScope> whereScopes
SqlSelect node to the scope used by its WHERE and HAVING
clauses.private final Map<SqlSelect,SqlValidatorScope> groupByScopes
SqlSelect node to the scope used by its GROUP BY clause.private final Map<SqlSelect,SqlValidatorScope> selectScopes
SqlSelect node to the scope used by its SELECT and HAVING
clauses.private final Map<SqlSelect,SqlValidatorScope> orderScopes
SqlSelect node to the scope used by its ORDER BY clause.private final Map<SqlSelect,SqlValidatorScope> cursorScopes
SqlSelect node that is the argument to a CURSOR
constructor to the scope of the result of that select nodeprivate TableScope tableScope
protected final Map<SqlNode,SqlValidatorNamespace> namespaces
private final Set<SqlNode> cursorSet
protected final Deque<SqlValidatorImpl.FunctionParamInfo> functionCallStack
private int nextGeneratedId
protected final RelDataTypeFactory typeFactory
protected final RelDataType unknownType
private final RelDataType booleanType
private final Map<SqlNode,RelDataType> nodeToTypeMap
private final AggFinder aggFinder
private final AggFinder aggOrOverFinder
private final AggFinder aggOrOverOrGroupFinder
private final AggFinder groupFinder
private final AggFinder overFinder
private final SqlConformance conformance
private SqlNode top
protected boolean expandIdentifiers
protected boolean expandColumnReferences
private boolean rewriteCalls
private NullCollation nullCollation
private boolean validatingSqlMerge
private boolean inWindow
private final SqlValidatorImpl.ValidationErrorFunction validationErrorFunction
protected SqlValidatorImpl(SqlOperatorTable opTab, SqlValidatorCatalogReader catalogReader, RelDataTypeFactory typeFactory, SqlConformance conformance)
opTab - Operator tablecatalogReader - Catalog readertypeFactory - Type factoryconformance - Compatibility modepublic SqlConformance getConformance()
SqlValidatorSqlConformanceEnum.DEFAULT.getConformance in interface SqlValidatorpublic SqlValidatorCatalogReader getCatalogReader()
SqlValidatorgetCatalogReader in interface SqlValidatorpublic SqlOperatorTable getOperatorTable()
SqlValidatorgetOperatorTable in interface SqlValidatorpublic RelDataTypeFactory getTypeFactory()
SqlValidatorgetTypeFactory in interface SqlValidatorpublic RelDataType getUnknownType()
SqlValidatorgetUnknownType in interface SqlValidatorpublic SqlNodeList expandStar(SqlNodeList selectList, SqlSelect select, boolean includeSystemVars)
SqlValidatorexpandStar in interface SqlValidatorselectList - Select clause to be expandedselect - QueryincludeSystemVars - Whether to include system variablespublic void declareCursor(SqlSelect select, SqlValidatorScope parentScope)
SqlValidatordeclareCursor in interface SqlValidatorselect - select expression associated with the cursorparentScope - scope of the parent query associated with the cursorpublic void pushFunctionCall()
SqlValidatorpushFunctionCall in interface SqlValidatorpublic void popFunctionCall()
SqlValidatorpopFunctionCall in interface SqlValidatorpublic String getParentCursor(String columnListParamName)
SqlValidatorgetParentCursor in interface SqlValidatorcolumnListParamName - name of the column list parameterprivate boolean expandSelectItem(SqlNode selectItem, SqlSelect select, RelDataType targetType, List<SqlNode> selectItems, Set<String> aliases, List<Map.Entry<String,RelDataType>> types, boolean includeSystemVars)
selectItem is "*" or "TABLE.*", expands it and returns
true; otherwise writes the unexpanded item.selectItem - Select-list itemselect - Containing select clauseselectItems - List that expanded items are written toaliases - Set of aliasestypes - List of data types in alias orderincludeSystemVars - If true include system vars in listsprivate boolean expandStar(List<SqlNode> selectItems, Set<String> aliases, List<Map.Entry<String,RelDataType>> types, boolean includeSystemVars, SelectScope scope, SqlNode node)
private boolean addOrExpandField(List<SqlNode> selectItems, Set<String> aliases, List<Map.Entry<String,RelDataType>> types, boolean includeSystemVars, SelectScope scope, SqlIdentifier id, RelDataTypeField field)
public SqlNode validate(SqlNode topNode)
SqlValidatorvalidate in interface SqlValidatortopNode - top of expression tree to be validatedpublic List<SqlMoniker> lookupHints(SqlNode topNode, SqlParserPos pos)
SqlValidatorWithHintsSqlValidator.validate(org.apache.calcite.sql.SqlNode).lookupHints in interface SqlValidatorWithHintstopNode - top of expression tree in which to lookup completion hintspos - indicates the position in the sql statement we want to get
completion hints for. For example, "select a.ename, b.deptno
from sales.emp a join sales.dept b "on a.deptno=b.deptno
where empno=1"; setting pos to 'Line 1, Column 17' returns
all the possible column names that can be selected from
sales.dept table setting pos to 'Line 1, Column 31' returns
all the possible table names in 'sales' schemaSqlMoniker (sql identifiers) that can fill in
at the indicated positionpublic SqlMoniker lookupQualifiedName(SqlNode topNode, SqlParserPos pos)
SqlValidatorWithHintsSqlIdentifier at a given
Parser Position in a parsed expression tree Note: call this only after
SqlValidator.validate(org.apache.calcite.sql.SqlNode) has been called.lookupQualifiedName in interface SqlValidatorWithHintstopNode - top of expression tree in which to lookup the qualified
name for the SqlIdentifierpos - indicates the position of the SqlIdentifier in
the SQL statement we want to get the qualified
name forSqlIdentifier
if the Parser position represents a valid SqlIdentifier. Else
return an empty stringvoid lookupSelectHints(SqlSelect select, SqlParserPos pos, Collection<SqlMoniker> hintList)
select - the Select node of the parsed expression treepos - indicates the position in the sql statement we want to get
completion hints forhintList - list of SqlMoniker (sql identifiers) that can
fill in at the indicated positionprivate void lookupSelectHints(SqlValidatorNamespace ns, SqlParserPos pos, Collection<SqlMoniker> hintList)
private void lookupFromHints(SqlNode node, SqlValidatorScope scope, SqlParserPos pos, Collection<SqlMoniker> hintList)
private void lookupJoinHints(SqlJoin join, SqlValidatorScope scope, SqlParserPos pos, Collection<SqlMoniker> hintList)
public final void lookupNameCompletionHints(SqlValidatorScope scope, List<String> names, SqlParserPos pos, Collection<SqlMoniker> hintList)
scope - Validation scopenames - Components of the identifierpos - positionhintList - a list of valid optionsprivate static void findAllValidUdfNames(List<String> names, SqlValidator validator, Collection<SqlMoniker> result)
private static void findAllValidFunctionNames(List<String> names, SqlValidator validator, Collection<SqlMoniker> result, SqlParserPos pos)
public SqlNode validateParameterizedExpression(SqlNode topNode, Map<String,RelDataType> nameToTypeMap)
SqlValidatorvalidateParameterizedExpression in interface SqlValidatortopNode - top of expression tree to be validatednameToTypeMap - map of simple name to RelDataType; used to
resolve SqlIdentifier referencesprivate SqlNode validateScopedExpression(SqlNode topNode, SqlValidatorScope scope)
public void validateQuery(SqlNode node, SqlValidatorScope scope, RelDataType targetRowType)
SqlValidatorValid queries include:
SELECT statement,
UNION, INTERSECT,
EXCEPT)
AS operator
validateQuery in interface SqlValidatornode - Query nodescope - Scope in which the query occurstargetRowType - Desired row type, must not be null, may be the data
type 'unknown'.protected void validateNamespace(SqlValidatorNamespace namespace, RelDataType targetRowType)
namespace - NamespacetargetRowType - Desired row type, must not be null, may be the data
type 'unknown'.public SqlValidatorScope getEmptyScope()
public SqlValidatorScope getCursorScope(SqlSelect select)
public SqlValidatorScope getWhereScope(SqlSelect select)
SqlValidatorgetWhereScope in interface SqlValidatorselect - Querypublic SqlValidatorScope getSelectScope(SqlSelect select)
SqlValidatorConsider
SELECT * FROM foo WHERE EXISTS ( SELECT deptno AS x FROM emp JOIN dept ON emp.deptno = dept.deptno WHERE emp.deptno = 5 GROUP BY deptno ORDER BY x)
What objects can be seen in each part of the sub-query?
SqlValidator.getFromScope(org.apache.calcite.sql.SqlSelect) , you can only see 'foo'.
SqlValidator.getWhereScope(org.apache.calcite.sql.SqlSelect)), GROUP BY (SqlValidator.getGroupScope(org.apache.calcite.sql.SqlSelect)),
SELECT (getSelectScope), and the ON clause of the JOIN
(SqlValidator.getJoinScope(org.apache.calcite.sql.SqlNode)) you can see 'emp', 'dept', and 'foo'.
SqlValidator.getOrderScope(org.apache.calcite.sql.SqlSelect)), you can see the column alias 'x';
and tables 'emp', 'dept', and 'foo'.
getSelectScope in interface SqlValidatorselect - SELECT statementpublic SelectScope getRawSelectScope(SqlSelect select)
SqlValidatorSelectScope; if this is an aggregation query, the
AggregatingScope is stripped away.getRawSelectScope in interface SqlValidatorselect - SELECT statementpublic SqlValidatorScope getHavingScope(SqlSelect select)
SqlValidatorgetHavingScope in interface SqlValidatorselect - SELECT statementpublic SqlValidatorScope getGroupScope(SqlSelect select)
SqlValidatorgetGroupScope in interface SqlValidatorselect - SELECT statementpublic SqlValidatorScope getFromScope(SqlSelect select)
SqlValidatorgetFromScope in interface SqlValidatorselect - SELECT statementpublic SqlValidatorScope getOrderScope(SqlSelect select)
SqlValidatorgetOrderScope in interface SqlValidatorselect - SELECT statementpublic SqlValidatorScope getMatchRecognizeScope(SqlMatchRecognize node)
SqlValidatorgetMatchRecognizeScope in interface SqlValidatornode - Match recognizepublic SqlValidatorScope getJoinScope(SqlNode node)
SqlValidatorgetJoinScope in interface SqlValidatornode - The item in the FROM clause which contains the ON or USING
expressionSqlValidator.getFromScope(org.apache.calcite.sql.SqlSelect)public SqlValidatorScope getOverScope(SqlNode node)
SqlValidatorgetOverScope in interface SqlValidatornode - Nodeprivate SqlValidatorNamespace getNamespace(SqlNode node, SqlValidatorScope scope)
private SqlValidatorNamespace getNamespace(SqlIdentifier id, DelegatingScope scope)
public SqlValidatorNamespace getNamespace(SqlNode node)
SqlValidatorFor example, in the query SELECT * FROM (SELECT * FROM t), t1 AS
alias, the both items in the FROM clause have a corresponding
namespace.
getNamespace in interface SqlValidatornode - Parse tree nodeprotected SqlNode performUnconditionalRewrites(SqlNode node, boolean underFrom)
node - expression to be rewrittenunderFrom - whether node appears directly under a FROM clauseprivate void rewriteMerge(SqlMerge call)
private SqlNode rewriteUpdateToMerge(SqlUpdate updateCall, SqlNode selfJoinSrcExpr)
protected SqlNode getSelfJoinExprForUpdate(SqlNode table, String alias)
table - identifier for table being updatedalias - 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.protected SqlSelect createSourceSelectForUpdate(SqlUpdate call)
call - Call to the UPDATE operatorprotected SqlSelect createSourceSelectForDelete(SqlDelete call)
call - Call to the DELETE operatorRelDataType getTableConstructorRowType(SqlCall values, SqlValidatorScope scope)
public RelDataType getValidatedNodeType(SqlNode node)
SqlValidatorgetValidatedNodeType in interface SqlValidatornode - the node of interestpublic RelDataType getValidatedNodeTypeIfKnown(SqlNode node)
SqlValidatorSqlValidator.getValidatedNodeType(org.apache.calcite.sql.SqlNode) instead.getValidatedNodeTypeIfKnown in interface SqlValidatornode - the node of interestpublic final void setValidatedNodeType(SqlNode node, RelDataType type)
SqlNode, now that it has been validated.
Unlike the base class method, this method is not deprecated. It is available from within Calcite, but is not part of the public API.
setValidatedNodeType in interface SqlValidatornode - A SQL parse tree node, never nulltype - Its type; must not be nullpublic void removeValidatedNodeType(SqlNode node)
SqlValidatorremoveValidatedNodeType in interface SqlValidatornode - node to be removedpublic RelDataType deriveType(SqlValidatorScope scope, SqlNode expr)
SqlValidatorderiveType in interface SqlValidatorscope - Syntactic scopeexpr - Parse tree nodeNULLRelDataType deriveTypeImpl(SqlValidatorScope scope, SqlNode operand)
public RelDataType deriveConstructorType(SqlValidatorScope scope, SqlCall call, SqlFunction unresolvedConstructor, SqlFunction resolvedConstructor, List<RelDataType> argTypes)
SqlValidatorderiveConstructorType in interface SqlValidatorscope - Scopecall - CallunresolvedConstructor - TODOresolvedConstructor - TODOargTypes - Types of argumentspublic CalciteException handleUnresolvedFunction(SqlCall call, SqlFunction unresolvedFunction, List<RelDataType> argTypes, List<String> argNames)
SqlValidatorhandleUnresolvedFunction in interface SqlValidatorcall - CallunresolvedFunction - Overloaded function which is the target of the
callargTypes - Types of argumentsargNames - Names of arguments, or null if call by positionprotected void inferUnknownTypes(RelDataType inferredType, SqlValidatorScope scope, SqlNode node)
protected void addToSelectList(List<SqlNode> list, Set<String> aliases, List<Map.Entry<String,RelDataType>> fieldList, SqlNode exp, SqlValidatorScope scope, boolean includeSystemVars)
public String deriveAlias(SqlNode node, int ordinal)
SqlValidatorordinal is less than zero, otherwise generates an
alias EXPR$ordinal.deriveAlias in interface SqlValidatornode - Expressionordinal - Ordinal of expressionpublic void setIdentifierExpansion(boolean expandIdentifiers)
SqlValidatorsetIdentifierExpansion in interface SqlValidatorexpandIdentifiers - new settingpublic void setColumnReferenceExpansion(boolean expandColumnReferences)
SqlValidatorsetColumnReferenceExpansion in interface SqlValidatorexpandColumnReferences - new settingpublic boolean getColumnReferenceExpansion()
getColumnReferenceExpansion in interface SqlValidatorpublic void setDefaultNullCollation(NullCollation nullCollation)
SqlValidatorsetDefaultNullCollation in interface SqlValidatorpublic NullCollation getDefaultNullCollation()
SqlValidatorgetDefaultNullCollation in interface SqlValidatorpublic void setCallRewrite(boolean rewriteCalls)
SqlValidatorsetCallRewrite in interface SqlValidatorrewriteCalls - new settingpublic boolean shouldExpandIdentifiers()
SqlValidatorshouldExpandIdentifiers in interface SqlValidatorprotected boolean shouldAllowIntermediateOrderBy()
private void registerMatchRecognize(SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlMatchRecognize call, SqlNode enclosingNode, String alias, boolean forceNullable)
protected MatchRecognizeNamespace createMatchRecognizeNameSpace(SqlMatchRecognize call, SqlNode enclosingNode)
protected void registerNamespace(SqlValidatorScope usingScope, String alias, SqlValidatorNamespace ns, boolean forceNullable)
usingScope - Parent scope (which will want to look for things in
this namespace)alias - Alias by which parent will refer to this namespacens - NamespaceforceNullable - Whether to force the type of namespace to be nullableprivate SqlNode registerFrom(SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlNode node, SqlNode enclosingNode, String alias, SqlNodeList extendList, boolean forceNullable)
parentScope and usingScope are often the same. They
differ when the namespace are not visible within the parent. (Example
needed.)
Likewise, enclosingNode and node are often the same.
enclosingNode is the topmost node within the FROM clause, from
which any decorations like an alias (AS alias) or a table
sample clause are stripped away to get node. Both are recorded in
the namespace.
parentScope - Parent scope which this scope turns to in order to
resolve objectsusingScope - Scope whose child list this scope should add itself tonode - Node which namespace is based onenclosingNode - Outermost node for namespace, including decorations
such as alias and sample clausealias - AliasextendList - Definitions of extended columnsforceNullable - Whether to force the type of namespace to be
nullable because it is in an outer joinnodeprivate static boolean isLateral(SqlNode node)
protected boolean shouldAllowOverRelation()
protected SelectNamespace createSelectNamespace(SqlSelect select, SqlNode enclosingNode)
SELECT node. Derived class may
override this factory method.select - Select nodeenclosingNode - Enclosing nodeprotected SetopNamespace createSetopNamespace(SqlCall call, SqlNode enclosingNode)
UNION,
INTERSECT, or EXCEPT). Derived class may override
this factory method.call - Call to set operationenclosingNode - Enclosing nodeprivate void registerQuery(SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlNode node, SqlNode enclosingNode, String alias, boolean forceNullable)
parentScope - Parent scope which this scope turns to in order to
resolve objectsusingScope - Scope whose child list this scope should add itself tonode - Query nodealias - Name of this query within its parent. Must be specified
if usingScope != nullprivate void registerQuery(SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlNode node, SqlNode enclosingNode, String alias, boolean forceNullable, boolean checkUpdate)
parentScope - Parent scope which this scope turns to in order to
resolve objectsusingScope - Scope whose child list this scope should add itself tonode - Query nodealias - Name of this query within its parent. Must be specified
if usingScope != nullcheckUpdate - if true, validate that the update feature is supported
if validating the update statementprivate void registerSetop(SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlNode node, SqlNode enclosingNode, String alias, boolean forceNullable)
private void registerWith(SqlValidatorScope parentScope, SqlValidatorScope usingScope, SqlWith with, SqlNode enclosingNode, String alias, boolean forceNullable, boolean checkUpdate)
public boolean isAggregate(SqlSelect select)
SqlValidatorSUM(x) OVER w, don't count.)isAggregate in interface SqlValidatorselect - SELECT statementprotected boolean isNestedAggregateWindow(SqlNode node)
protected boolean isOverAggregateWindow(SqlNode node)
protected SqlNode getAggregate(SqlSelect select)
select to be an aggregate query, or null if it
is not an aggregate query.
The node is useful context for error messages, but you cannot assume that the node is the only aggregate function.
private SqlNode getAgg(SqlSelect select)
public boolean isAggregate(SqlNode selectNode)
SqlValidatorisAggregate in interface SqlValidatorselectNode - Expression in SELECT clauseprivate void validateNodeFeature(SqlNode node)
private void registerSubQueries(SqlValidatorScope parentScope, SqlNode node)
private void registerOperandSubQueries(SqlValidatorScope parentScope, SqlCall call, int operandOrdinal)
parentScope - Parent scopecall - CalloperandOrdinal - Ordinal of operand within callSqlOperator.argumentMustBeScalar(int)public void validateIdentifier(SqlIdentifier id, SqlValidatorScope scope)
SqlValidatorvalidateIdentifier in interface SqlValidatorid - Identifierscope - Naming scopepublic void validateLiteral(SqlLiteral literal)
SqlValidatorvalidateLiteral in interface SqlValidatorliteral - Literalprivate void validateLiteralAsDouble(SqlLiteral literal)
public void validateIntervalQualifier(SqlIntervalQualifier qualifier)
SqlValidatorSqlIntervalQualifiervalidateIntervalQualifier in interface SqlValidatorqualifier - Interval qualifierprotected void validateFrom(SqlNode node, RelDataType targetRowType, SqlValidatorScope scope)
node - Node in FROM clause, typically a table or derived
tabletargetRowType - Desired row type of this expression, or
unknownType if not fussy. Must not be null.scope - Scopeprotected void validateOver(SqlCall call, SqlValidatorScope scope)
private void checkRollUpInUsing(SqlIdentifier identifier, SqlNode leftOrRight)
protected void validateJoin(SqlJoin join, SqlValidatorScope scope)
private void validateNoAggs(AggFinder aggFinder, SqlNode node, String clause)
aggFinder - Finder for the particular kind(s) of aggregate functionnode - Parse treeclause - Name of clause: "WHERE", "GROUP BY", "ON"private RelDataType validateUsingCol(SqlIdentifier id, SqlNode leftOrRight)
protected void validateSelect(SqlSelect select, RelDataType targetRowType)
select - Select statementtargetRowType - Desired row type, must not be null, may be the data
type 'unknown'.private void checkRollUpInSelectList(SqlSelect select)
private void checkRollUpInGroupBy(SqlSelect select)
private void checkRollUpInOrderBy(SqlSelect select)
private void checkRollUpInWindow(SqlWindow window, SqlValidatorScope scope)
private void checkRollUpInWindowDecl(SqlSelect select)
private void checkRollUp(SqlNode grandParent, SqlNode parent, SqlNode current, SqlValidatorScope scope, String optionalClause)
private void checkRollUp(SqlNode grandParent, SqlNode parent, SqlNode current, SqlValidatorScope scope)
private Pair<String,String> findTableColumnPair(SqlIdentifier identifier, SqlValidatorScope scope)
private boolean isRolledUpColumnAllowedInAgg(SqlIdentifier identifier, SqlValidatorScope scope, SqlCall aggCall, SqlNode parent)
private boolean isRolledUpColumn(SqlIdentifier identifier, SqlValidatorScope scope)
private Table findTable(CalciteSchema schema, String tableName, boolean caseSensitive)
private Table findTable(String alias)
Table associated with itprivate boolean shouldCheckForRollUp(SqlNode from)
private void validateModality(SqlNode query)
private SqlModality deduceModality(SqlNode query)
public boolean validateModality(SqlSelect select, SqlModality modality, boolean fail)
SqlValidatorvalidateModality in interface SqlValidatorselect - Querymodality - Modality (streaming or relational)fail - Whether to throw a user error if does not support required
modalityprivate boolean hasSortedPrefix(SelectScope scope, SqlNodeList orderList)
private boolean isSortCompatible(SelectScope scope, SqlNode node, boolean descending)
protected void validateWindowClause(SqlSelect select)
public void validateWith(SqlWith with, SqlValidatorScope scope)
validateWith in interface SqlValidatorpublic void validateWithItem(SqlWithItem withItem)
validateWithItem in interface SqlValidatorpublic void validateSequenceValue(SqlValidatorScope scope, SqlIdentifier id)
validateSequenceValue in interface SqlValidatorpublic SqlValidatorScope getWithScope(SqlNode withItem)
getWithScope in interface SqlValidatorprotected void validateOrderList(SqlSelect select)
select - Select statementprivate void validateGroupByItem(SqlSelect select, SqlNode groupByItem)
select - Select statementgroupByItem - GROUP BY clause itemprivate void validateOrderItem(SqlSelect select, SqlNode orderItem)
select - Select statementorderItem - ORDER BY clause itempublic SqlNode expandOrderExpr(SqlSelect select, SqlNode orderExpr)
SqlValidatorThis is made necessary by a couple of dialect 'features':
expandOrderExpr in interface SqlValidatorselect - Select statement which contains ORDER BYorderExpr - Expression in the ORDER BY clause.protected void validateGroupClause(SqlSelect select)
private void validateGroupItem(SqlValidatorScope groupScope, AggregatingSelectScope aggregatingScope, SqlNode groupItem)
private void validateGroupingSets(SqlValidatorScope groupScope, AggregatingSelectScope aggregatingScope, SqlCall groupItem)
protected void validateWhereClause(SqlSelect select)
protected void validateWhereOrOn(SqlValidatorScope scope, SqlNode condition, String clause)
protected void validateHavingClause(SqlSelect select)
protected RelDataType validateSelectList(SqlNodeList selectItems, SqlSelect select, RelDataType targetRowType)
private void validateExpr(SqlNode expr, SqlValidatorScope scope)
expr - Expressionscope - Scope in which expression occursprivate void handleScalarSubQuery(SqlSelect parentSelect, SqlSelect selectItem, List<SqlNode> expandedSelectItems, Set<String> aliasList, List<Map.Entry<String,RelDataType>> fieldList)
parentSelect - base SqlSelect itemselectItem - child SqlSelect from select listexpandedSelectItems - Select items after processingaliasList - built from user or system valuesfieldList - Built up entries for each select list entryprotected RelDataType createTargetRowType(SqlValidatorTable table, SqlNodeList targetColumnList, boolean append)
table - Target table for INSERT/UPDATEtargetColumnList - List of target columns, or null if not specifiedappend - Whether to append fields to those in
baseRowTypepublic void validateInsert(SqlInsert insert)
SqlValidatorvalidateInsert in interface SqlValidatorinsert - INSERT statementprivate void checkConstraint(SqlValidatorTable validatorTable, SqlNode source, RelDataType targetRowType)
validatorTable - Table that may wrap a ModifiableViewTablesource - The values being insertedtargetRowType - The target type for the viewprivate void checkConstraint(SqlValidatorTable validatorTable, SqlUpdate update, RelDataType targetRowType)
validatorTable - A SqlValidatorTable that may wrap a
ModifiableViewTableupdate - The UPDATE parse tree nodetargetRowType - The target typeprivate void checkFieldCount(SqlNode node, SqlValidatorTable table, SqlNode source, RelDataType logicalSourceRowType, RelDataType logicalTargetRowType)
private boolean isValuesWithDefault(SqlNode source, int column)
DEFAULT to populate a given
column.private boolean isRowWithDefault(SqlNode operand, int column)
protected RelDataType getLogicalTargetRowType(RelDataType targetRowType, SqlInsert insert)
protected RelDataType getLogicalSourceRowType(RelDataType sourceRowType, SqlInsert insert)
protected void checkTypeAssignment(RelDataType sourceRowType, RelDataType targetRowType, SqlNode query)
private SqlNode getNthExpr(SqlNode query, int ordinal, int sourceCount)
query - Queryordinal - Ordinal of expressionsourceCount - Number of expressionspublic void validateDelete(SqlDelete call)
SqlValidatorvalidateDelete in interface SqlValidatorcall - DELETE statementpublic void validateUpdate(SqlUpdate call)
SqlValidatorvalidateUpdate in interface SqlValidatorcall - UPDATE statementpublic void validateMerge(SqlMerge call)
SqlValidatorvalidateMerge in interface SqlValidatorcall - MERGE statementprivate void validateAccess(SqlNode node, SqlValidatorTable table, SqlAccessEnum requiredAccess)
table - TablerequiredAccess - Access requested on tableprotected void validateValues(SqlCall node, RelDataType targetRowType, SqlValidatorScope scope)
node - Values clausetargetRowType - Row type which expression must conform toscope - Scope within which clause occurspublic void validateDataType(SqlDataTypeSpec dataType)
SqlValidatorvalidateDataType in interface SqlValidatordataType - Data typepublic void validateDynamicParam(SqlDynamicParam dynamicParam)
SqlValidatorvalidateDynamicParam in interface SqlValidatordynamicParam - Dynamic parameterpublic SqlValidatorImpl.ValidationErrorFunction getValidationErrorFunction()
public CalciteContextException newValidationError(SqlNode node, Resources.ExInst<SqlValidatorException> e)
SqlValidatorNote that the input exception is checked (it derives from
Exception) and the output exception is unchecked (it derives from
RuntimeException). This is intentional -- it should remind code
authors to provide context for their validation errors.
newValidationError in interface SqlValidatornode - The place where the exception occurred, not nulle - The validation errorprotected SqlWindow getWindowByName(SqlIdentifier id, SqlValidatorScope scope)
public SqlWindow resolveWindow(SqlNode windowOrRef, SqlValidatorScope scope, boolean populateBounds)
SqlValidatorSELECT sum(x) OVER (PARTITION
BY x ORDER BY y), sum(y) OVER w1, sum(z) OVER (w ORDER BY y) FROM t
WINDOW w AS (PARTITION BY x) all aggregations have the same
resolved window specification (PARTITION BY x ORDER BY y).resolveWindow in interface SqlValidatorwindowOrRef - Either the name of a window (a SqlIdentifier)
or a window specification (a SqlWindow).scope - Scope in which to resolve window namespopulateBounds - Whether to populate bounds. Doing so may alter the
definition of the window. It is recommended that
populate bounds when translating to physical algebra,
but not when validating.SqlValidatorNamespace lookupFieldNamespace(RelDataType rowType, String name)
public void validateWindow(SqlNode windowOrId, SqlValidatorScope scope, SqlCall call)
SqlValidatoridentifier referencing a window, or an
inline window specification.validateWindow in interface SqlValidatorwindowOrId - SqlNode that can be either SqlWindow with all the
components of a window spec or a SqlIdentifier with the
name of a window spec.scope - Naming scopecall - the SqlNode if a function call if the window is attached
to one.public void validateMatchRecognize(SqlCall call)
SqlValidatorvalidateMatchRecognize in interface SqlValidatorcall - MATCH_RECOGNIZE clauseprivate List<Map.Entry<String,RelDataType>> validateMeasure(SqlMatchRecognize mr, MatchRecognizeScope scope, boolean allRows)
private void validateDefinitions(SqlMatchRecognize mr, MatchRecognizeScope scope)
private SqlNode navigationInDefine(SqlNode node, String alpha)
PREV(B.price) to
LAST(B.price, 0).public void validateAggregateParams(SqlCall aggCall, SqlNode filter, SqlValidatorScope scope)
SqlValidatorvalidateAggregateParams in interface SqlValidatoraggCall - Function containing COLUMN_LIST parameterfilter - Filter, or nullscope - Syntactic scopepublic void validateCall(SqlCall call, SqlValidatorScope scope)
SqlValidatorvalidateCall in interface SqlValidatorcall - Operator callscope - Naming scopeprotected void validateFeature(Feature feature, SqlParserPos context)
feature - feature being used, represented as a resource instancecontext - parser position context for error reporting, or null ifpublic SqlNode expand(SqlNode expr, SqlValidatorScope scope)
SqlValidatorexpand in interface SqlValidatorexpr - Expressionscope - Scopepublic SqlNode expandGroupByOrHavingExpr(SqlNode expr, SqlValidatorScope scope, SqlSelect select, boolean havingExpression)
public boolean isSystemField(RelDataTypeField field)
SqlValidatorIn the default implementation, always returns false.
isSystemField in interface SqlValidatorfield - Fieldpublic List<List<String>> getFieldOrigins(SqlNode sqlQuery)
SqlValidatorThe returned list is never null, and has one element for each field in the row type. Each element is a list of four elements (catalog, schema, table, column), or may be null if the column is an expression.
getFieldOrigins in interface SqlValidatorsqlQuery - Querypublic RelDataType getParameterRowType(SqlNode sqlQuery)
SqlValidatorgetParameterRowType in interface SqlValidatorsqlQuery - Querypublic void validateColumnListParams(SqlFunction function, List<RelDataType> argTypes, List<SqlNode> operands)
SqlValidatorvalidateColumnListParams in interface SqlValidatorfunction - function containing COLUMN_LIST parameterargTypes - function argumentsoperands - operands passed into the function callprivate static boolean isPhysicalNavigation(SqlKind kind)
private static boolean isLogicalNavigation(SqlKind kind)
private static boolean isAggregation(SqlKind kind)
private static boolean isRunningOrFinal(SqlKind kind)
private static boolean isSingleVarRequired(SqlKind kind)
Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.