Package org.apache.calcite.sql.validate
Class IdentifierNamespace
- java.lang.Object
-
- org.apache.calcite.sql.validate.AbstractNamespace
-
- org.apache.calcite.sql.validate.IdentifierNamespace
-
- All Implemented Interfaces:
SqlValidatorNamespace
- Direct Known Subclasses:
SqlValidatorImpl.DmlNamespace
public class IdentifierNamespace extends AbstractNamespace
Namespace whose contents are defined by the type of anidentifier
.
-
-
Field Summary
Fields Modifier and Type Field Description SqlNodeList
extendList
private SqlIdentifier
id
private java.util.List<Pair<SqlNode,SqlMonotonicity>>
monotonicExprs
List of monotonic expressions.private SqlValidatorScope
parentScope
private SqlValidatorNamespace
resolvedNamespace
The underlying namespace.-
Fields inherited from class org.apache.calcite.sql.validate.AbstractNamespace
enclosingNode, rowType, type, validator
-
-
Constructor Summary
Constructors Constructor Description IdentifierNamespace(SqlValidatorImpl validator, SqlIdentifier id, SqlNodeList extendList, SqlNode enclosingNode, SqlValidatorScope parentScope)
Creates an IdentifierNamespace.IdentifierNamespace(SqlValidatorImpl validator, SqlNode node, SqlNode enclosingNode, SqlValidatorScope parentScope)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SqlIdentifier
getId()
java.util.List<Pair<SqlNode,SqlMonotonicity>>
getMonotonicExprs()
Returns a list of expressions which are monotonic in this namespace.SqlMonotonicity
getMonotonicity(java.lang.String columnName)
Returns whether and how a given column is sorted.SqlNode
getNode()
Returns the parse tree node at the root of this namespace.SqlValidatorTable
getTable()
Returns the underlying table, or null if there is none.SqlValidatorNamespace
resolve()
If this namespace resolves to another namespace, returns that namespace, following links to the end of the chain.private SqlValidatorNamespace
resolveImpl(SqlIdentifier id)
protected static Pair<SqlIdentifier,SqlNodeList>
split(SqlNode node)
boolean
supportsModality(SqlModality modality)
Returns whether this namespace is capable of giving results of the desired modality.RelDataType
validateImpl(RelDataType targetRowType)
Validates this scope and returns the type of the records it returns.-
Methods inherited from class org.apache.calcite.sql.validate.AbstractNamespace
convertToStruct, fieldExists, getEnclosingNode, getRowType, getRowTypeSansSystemColumns, getType, getValidator, isWrapperFor, lookupChild, makeNullable, setType, toStruct, translate, unwrap, validate
-
-
-
-
Field Detail
-
id
private final SqlIdentifier id
-
parentScope
private final SqlValidatorScope parentScope
-
extendList
public final SqlNodeList extendList
-
resolvedNamespace
private SqlValidatorNamespace resolvedNamespace
The underlying namespace. Often aTableNamespace
. Set on validate.
-
monotonicExprs
private java.util.List<Pair<SqlNode,SqlMonotonicity>> monotonicExprs
List of monotonic expressions. Set on validate.
-
-
Constructor Detail
-
IdentifierNamespace
IdentifierNamespace(SqlValidatorImpl validator, SqlIdentifier id, @Nullable SqlNodeList extendList, SqlNode enclosingNode, SqlValidatorScope parentScope)
Creates an IdentifierNamespace.- Parameters:
validator
- Validatorid
- Identifier node (or "identifier EXTEND column-list")extendList
- Extension columns, or nullenclosingNode
- Enclosing nodeparentScope
- Parent scope which this namespace turns to in order to
-
IdentifierNamespace
IdentifierNamespace(SqlValidatorImpl validator, SqlNode node, SqlNode enclosingNode, SqlValidatorScope parentScope)
-
-
Method Detail
-
split
protected static Pair<SqlIdentifier,SqlNodeList> split(SqlNode node)
-
resolveImpl
private SqlValidatorNamespace resolveImpl(SqlIdentifier id)
-
validateImpl
public RelDataType validateImpl(RelDataType targetRowType)
Description copied from class:AbstractNamespace
Validates this scope and returns the type of the records it returns. External users should callAbstractNamespace.validate(org.apache.calcite.rel.type.RelDataType)
, which uses theAbstractNamespace.status
field to protect against cycles.- Specified by:
validateImpl
in classAbstractNamespace
- Parameters:
targetRowType
- Desired row type, must not be null, may be the data type 'unknown'.- Returns:
- record data type, never null
-
getId
public SqlIdentifier getId()
-
getNode
public SqlNode getNode()
Description copied from interface:SqlValidatorNamespace
Returns the parse tree node at the root of this namespace.- Returns:
- parse tree node; null for
TableNamespace
-
resolve
public SqlValidatorNamespace resolve()
Description copied from interface:SqlValidatorNamespace
If this namespace resolves to another namespace, returns that namespace, following links to the end of the chain.A
WITH
) clause defines table names that resolve to queries (the body of the with-item). AnIdentifierNamespace
typically resolves to aTableNamespace
.You must not call this method before
SqlValidatorNamespace.validate(RelDataType)
has completed.- Specified by:
resolve
in interfaceSqlValidatorNamespace
- Overrides:
resolve
in classAbstractNamespace
-
getTable
public SqlValidatorTable getTable()
Description copied from interface:SqlValidatorNamespace
Returns the underlying table, or null if there is none.- Specified by:
getTable
in interfaceSqlValidatorNamespace
- Overrides:
getTable
in classAbstractNamespace
-
getMonotonicExprs
public java.util.List<Pair<SqlNode,SqlMonotonicity>> getMonotonicExprs()
Description copied from interface:SqlValidatorNamespace
Returns a list of expressions which are monotonic in this namespace. For example, if the namespace represents a relation ordered by a column called "TIMESTAMP", then the list would contain aSqlIdentifier
called "TIMESTAMP".- Specified by:
getMonotonicExprs
in interfaceSqlValidatorNamespace
- Overrides:
getMonotonicExprs
in classAbstractNamespace
-
getMonotonicity
public SqlMonotonicity getMonotonicity(java.lang.String columnName)
Description copied from interface:SqlValidatorNamespace
Returns whether and how a given column is sorted.- Specified by:
getMonotonicity
in interfaceSqlValidatorNamespace
- Overrides:
getMonotonicity
in classAbstractNamespace
-
supportsModality
public boolean supportsModality(SqlModality modality)
Description copied from interface:SqlValidatorNamespace
Returns whether this namespace is capable of giving results of the desired modality.true
means streaming,false
means relational.- Specified by:
supportsModality
in interfaceSqlValidatorNamespace
- Overrides:
supportsModality
in classAbstractNamespace
- Parameters:
modality
- Modality
-
-