public class SelectNamespace extends Object
SelectScope,
SetopNamespace| Modifier and Type | Field and Description |
|---|---|
protected @Nullable SqlNode |
enclosingNode |
protected @Nullable RelDataType |
rowType
Type of the output row, which comprises the name and type of each output
column.
|
protected @Nullable RelDataType |
type
As
rowType, but not necessarily a struct. |
protected SqlValidatorImpl |
validator |
| Constructor and Description |
|---|
SelectNamespace(SqlValidatorImpl validator,
SqlSelect select,
SqlNode enclosingNode)
Creates a SelectNamespace.
|
| Modifier and Type | Method and Description |
|---|---|
protected RelDataType |
convertToStruct(RelDataType type) |
boolean |
fieldExists(String name)
Returns whether this namespace has a field of a given name.
|
@Nullable SqlNode |
getEnclosingNode()
Returns the parse tree node that at is at the root of this namespace and
includes all decorations.
|
List<Pair<SqlNode,SqlMonotonicity>> |
getMonotonicExprs()
Returns a list of expressions which are monotonic in this namespace.
|
SqlMonotonicity |
getMonotonicity(String columnName)
Returns whether and how a given column is sorted.
|
@Nullable SqlNode |
getNode()
Returns the parse tree node at the root of this namespace.
|
RelDataType |
getRowType()
Returns the row type of this namespace, which comprises a list of names
and types of the output columns.
|
RelDataType |
getRowTypeSansSystemColumns()
Returns the row type of this namespace, sans any system columns.
|
@Nullable SqlValidatorTable |
getTable()
Returns the underlying table, or null if there is none.
|
RelDataType |
getType()
Returns the type of this namespace.
|
SqlValidator |
getValidator()
Returns the validator.
|
boolean |
isWrapperFor(Class<?> clazz)
Returns whether this namespace implements a given interface, or wraps a
class which does.
|
@Nullable SqlValidatorNamespace |
lookupChild(String name)
Looks up a child namespace of a given name.
|
void |
makeNullable() |
SqlValidatorNamespace |
resolve()
If this namespace resolves to another namespace, returns that namespace,
following links to the end of the chain.
|
void |
setType(RelDataType type)
Sets the type of this namespace.
|
boolean |
supportsModality(SqlModality modality)
Returns whether this namespace is capable of giving results of the desired
modality.
|
protected RelDataType |
toStruct(RelDataType type,
@Nullable SqlNode unnest)
Converts a type to a struct if it is not already.
|
String |
translate(String name) |
<T> T |
unwrap(Class<T> clazz)
Returns this namespace, or a wrapped namespace, cast to a particular
class.
|
void |
validate(RelDataType targetRowType)
Validates this namespace.
|
RelDataType |
validateImpl(RelDataType targetRowType)
Validates this scope and returns the type of the records it returns.
|
protected final SqlValidatorImpl validator
protected @Nullable RelDataType rowType
protected @Nullable RelDataType type
rowType, but not necessarily a struct.protected final @Nullable SqlNode enclosingNode
public SelectNamespace(SqlValidatorImpl validator, SqlSelect select, SqlNode enclosingNode)
validator - Validateselect - Select nodeenclosingNode - Enclosing nodepublic @Nullable SqlNode getNode()
SqlValidatorNamespaceTableNamespacepublic RelDataType validateImpl(RelDataType targetRowType)
validate(org.apache.calcite.rel.type.RelDataType), which uses the
status field to protect against cycles.targetRowType - Desired row type, must not be null, may be the data
type 'unknown'.public boolean supportsModality(SqlModality modality)
SqlValidatorNamespacetrue means streaming, false means relational.supportsModality in interface SqlValidatorNamespacemodality - Modalitypublic SqlMonotonicity getMonotonicity(String columnName)
SqlValidatorNamespacegetMonotonicity in interface SqlValidatorNamespacepublic SqlValidator getValidator()
SqlValidatorNamespacegetValidator in interface SqlValidatorNamespacepublic final void validate(RelDataType targetRowType)
SqlValidatorNamespaceIf the scope has already been validated, does nothing.
Please call SqlValidatorImpl.validateNamespace(org.apache.calcite.sql.validate.SqlValidatorNamespace, org.apache.calcite.rel.type.RelDataType) rather than
calling this method directly.
validate in interface SqlValidatorNamespacetargetRowType - Desired row type, must not be null, may be the data
type 'unknown'.public RelDataType getRowType()
SqlValidatorNamespacegetRowType in interface SqlValidatorNamespacepublic RelDataType getRowTypeSansSystemColumns()
SqlValidatorNamespacegetRowTypeSansSystemColumns in interface SqlValidatorNamespacepublic RelDataType getType()
SqlValidatorNamespacegetType in interface SqlValidatorNamespacepublic void setType(RelDataType type)
SqlValidatorNamespaceAllows the type for the namespace to be explicitly set, but usually is
called during SqlValidatorNamespace.validate(RelDataType).
Implicitly also sets the row type. If the type is not a struct, then the row type is the type wrapped as a struct with a single column, otherwise the type and row type are the same.
setType in interface SqlValidatorNamespacepublic @Nullable SqlNode getEnclosingNode()
SqlValidatorNamespaceSqlValidatorNamespace.getNode().getEnclosingNode in interface SqlValidatorNamespacepublic @Nullable SqlValidatorTable getTable()
SqlValidatorNamespacegetTable in interface SqlValidatorNamespacepublic @Nullable SqlValidatorNamespace lookupChild(String name)
SqlValidatorNamespaceFor example, in the query select e.name from emps as e,
e is an IdentifierNamespace which has a child
name which is a FieldNamespace.
lookupChild in interface SqlValidatorNamespacename - Name of namespacepublic boolean fieldExists(String name)
SqlValidatorNamespacefieldExists in interface SqlValidatorNamespacename - Field namepublic List<Pair<SqlNode,SqlMonotonicity>> getMonotonicExprs()
SqlValidatorNamespaceSqlIdentifier called "TIMESTAMP".getMonotonicExprs in interface SqlValidatorNamespacepublic void makeNullable()
makeNullable in interface SqlValidatorNamespacepublic SqlValidatorNamespace resolve()
SqlValidatorNamespaceA WITH) clause defines table names that resolve to queries
(the body of the with-item). An IdentifierNamespace typically
resolves to a TableNamespace.
You must not call this method before SqlValidatorNamespace.validate(RelDataType) has
completed.
resolve in interface SqlValidatorNamespacepublic <T> T unwrap(Class<T> clazz)
SqlValidatorNamespaceunwrap in interface SqlValidatorNamespaceclazz - Desired typepublic boolean isWrapperFor(Class<?> clazz)
SqlValidatorNamespaceisWrapperFor in interface SqlValidatorNamespaceclazz - Interfaceprotected RelDataType convertToStruct(RelDataType type)
protected RelDataType toStruct(RelDataType type, @Nullable SqlNode unnest)
Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.