Package org.apache.calcite.sql.validate
Class FieldNamespace
- java.lang.Object
-
- org.apache.calcite.sql.validate.AbstractNamespace
-
- org.apache.calcite.sql.validate.FieldNamespace
-
- All Implemented Interfaces:
SqlValidatorNamespace
class FieldNamespace extends AbstractNamespace
Implementation ofSqlValidatorNamespace
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.
-
-
Field Summary
-
Fields inherited from class org.apache.calcite.sql.validate.AbstractNamespace
enclosingNode, rowType, type, validator
-
-
Constructor Summary
Constructors Constructor Description FieldNamespace(SqlValidatorImpl validator, RelDataType dataType)
Creates a FieldNamespace.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class org.apache.calcite.sql.validate.AbstractNamespace
convertToStruct, getEnclosingNode, getMonotonicExprs, getMonotonicity, getRowType, getRowTypeSansSystemColumns, getTable, getType, getValidator, isWrapperFor, makeNullable, resolve, supportsModality, toStruct, translate, unwrap, validate
-
-
-
-
Constructor Detail
-
FieldNamespace
FieldNamespace(SqlValidatorImpl validator, RelDataType dataType)
Creates a FieldNamespace.- Parameters:
validator
- ValidatordataType
- Data type of field
-
-
Method Detail
-
setType
public void setType(RelDataType type)
Description copied from interface:SqlValidatorNamespace
Sets the type of this namespace.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.
- Specified by:
setType
in interfaceSqlValidatorNamespace
- Overrides:
setType
in classAbstractNamespace
-
validateImpl
protected 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
-
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
-
lookupChild
public SqlValidatorNamespace lookupChild(java.lang.String name)
Description copied from interface:SqlValidatorNamespace
Looks up a child namespace of a given name.For example, in the query
select e.name from emps as e
,e
is anIdentifierNamespace
which has a childname
which is aFieldNamespace
.- Specified by:
lookupChild
in interfaceSqlValidatorNamespace
- Overrides:
lookupChild
in classAbstractNamespace
- Parameters:
name
- Name of namespace- Returns:
- Namespace
-
fieldExists
public boolean fieldExists(java.lang.String name)
Description copied from interface:SqlValidatorNamespace
Returns whether this namespace has a field of a given name.- Specified by:
fieldExists
in interfaceSqlValidatorNamespace
- Overrides:
fieldExists
in classAbstractNamespace
- Parameters:
name
- Field name- Returns:
- Whether field exists
-
-