class FieldNamespace extends AbstractNamespace
SqlValidatorNamespace
for a field of a record.
A field is not a very interesting namespace - except if the field has a record or multiset type - but this class exists to make fields behave similarly to other records for purposes of name resolution.
enclosingNode, rowType, type, validator
Constructor and Description |
---|
FieldNamespace(SqlValidatorImpl validator,
RelDataType dataType)
Creates a FieldNamespace.
|
Modifier and Type | Method and Description |
---|---|
boolean |
fieldExists(java.lang.String name)
Returns whether this namespace has a field of a given name.
|
SqlNode |
getNode()
Returns the parse tree node at the root of this namespace.
|
SqlValidatorNamespace |
lookupChild(java.lang.String name)
Looks up a child namespace of a given name.
|
void |
setType(RelDataType type)
Sets the type of this namespace.
|
protected RelDataType |
validateImpl(RelDataType targetRowType)
Validates this scope and returns the type of the records it returns.
|
convertToStruct, getEnclosingNode, getMonotonicExprs, getMonotonicity, getRowType, getRowTypeSansSystemColumns, getTable, getType, getValidator, isWrapperFor, makeNullable, resolve, supportsModality, toStruct, translate, unwrap, validate
FieldNamespace(SqlValidatorImpl validator, RelDataType dataType)
validator
- ValidatordataType
- Data type of fieldpublic void setType(RelDataType type)
SqlValidatorNamespace
Allows 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 SqlValidatorNamespace
setType
in class AbstractNamespace
protected RelDataType validateImpl(RelDataType targetRowType)
AbstractNamespace
AbstractNamespace.validate(org.apache.calcite.rel.type.RelDataType)
, which uses the
AbstractNamespace.status
field to protect against cycles.validateImpl
in class AbstractNamespace
targetRowType
- Desired row type, must not be null, may be the data
type 'unknown'.public SqlNode getNode()
SqlValidatorNamespace
TableNamespace
public SqlValidatorNamespace lookupChild(java.lang.String name)
SqlValidatorNamespace
For 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 SqlValidatorNamespace
lookupChild
in class AbstractNamespace
name
- Name of namespacepublic boolean fieldExists(java.lang.String name)
SqlValidatorNamespace
fieldExists
in interface SqlValidatorNamespace
fieldExists
in class AbstractNamespace
name
- Field nameCopyright © 2012–2019 The Apache Software Foundation. All rights reserved.