Package org.apache.calcite.sql.validate
Class SqlValidatorImpl.DmlNamespace
java.lang.Object
org.apache.calcite.sql.validate.IdentifierNamespace
org.apache.calcite.sql.validate.SqlValidatorImpl.DmlNamespace
- All Implemented Interfaces:
SqlValidatorNamespace
- Enclosing class:
SqlValidatorImpl
Common base class for DML statement namespaces.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final @Nullable SqlNode
protected ImmutableBitSet
Ordinals of fields that must be filtered.protected @Nullable RelDataType
Type of the output row, which comprises the name and type of each output column.protected @Nullable RelDataType
AsrowType
, but not necessarily a struct.protected final SqlValidatorImpl
Fields inherited from class org.apache.calcite.sql.validate.IdentifierNamespace
extendList
-
Constructor Summary
ModifierConstructorDescriptionprotected
DmlNamespace
(SqlValidatorImpl validator, SqlNode id, SqlNode enclosingNode, SqlValidatorScope parentScope) -
Method Summary
Modifier and TypeMethodDescriptionprotected RelDataType
convertToStruct
(RelDataType type) @Nullable RelDataTypeField
Returns a field of a given name, or null.@Nullable SqlNode
Returns the parse tree node that at is at the root of this namespace and includes all decorations.Returns the ordinals (in the row type) of the "must-filter" fields, fields that that must be filtered in a query.Returns the row type of this namespace, which comprises a list of names and types of the output columns.Returns the row type of this namespace, sans any system columns.getType()
Returns the type of this namespace.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
void
setType
(RelDataType type) Sets the type of this namespace.protected RelDataType
toStruct
(RelDataType type, @Nullable SqlNode unnest) Converts a type to a struct if it is not already.<T> @Nullable T
Returns this namespace, or a wrapped namespace, cast to a particular class.final void
validate
(RelDataType targetRowType) Validates this namespace.Methods inherited from class org.apache.calcite.sql.validate.IdentifierNamespace
getId, getMonotonicExprs, getMonotonicity, getNode, getTable, resolve, split, supportsModality, validateImpl
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.sql.validate.SqlValidatorNamespace
fieldExists
-
Field Details
-
validator
-
rowType
Type of the output row, which comprises the name and type of each output column. Set on validate. -
type
AsrowType
, but not necessarily a struct. -
mustFilterFields
Ordinals of fields that must be filtered. Initially the empty set, but should typically be re-assigned on validate. -
enclosingNode
-
-
Constructor Details
-
DmlNamespace
protected DmlNamespace(SqlValidatorImpl validator, SqlNode id, SqlNode enclosingNode, SqlValidatorScope parentScope)
-
-
Method Details
-
getValidator
Description copied from interface:SqlValidatorNamespace
Returns the validator.- Specified by:
getValidator
in interfaceSqlValidatorNamespace
- Returns:
- validator
-
validate
Description copied from interface:SqlValidatorNamespace
Validates this namespace.If 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.- Specified by:
validate
in interfaceSqlValidatorNamespace
- Parameters:
targetRowType
- Desired row type, must not be null, may be the data type 'unknown'.
-
getRowType
Description copied from interface:SqlValidatorNamespace
Returns the row type of this namespace, which comprises a list of names and types of the output columns. If the scope's type has not yet been derived, derives it.- Specified by:
getRowType
in interfaceSqlValidatorNamespace
- Returns:
- Row type of this namespace, never null, always a struct
-
getRowTypeSansSystemColumns
Description copied from interface:SqlValidatorNamespace
Returns the row type of this namespace, sans any system columns.- Specified by:
getRowTypeSansSystemColumns
in interfaceSqlValidatorNamespace
- Returns:
- Row type sans system columns
-
getType
Description copied from interface:SqlValidatorNamespace
Returns the type of this namespace.- Specified by:
getType
in interfaceSqlValidatorNamespace
- Returns:
- Row type converted to struct
-
setType
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
-
getEnclosingNode
Description copied from interface:SqlValidatorNamespace
Returns the parse tree node that at is at the root of this namespace and includes all decorations. If there are no decorations, returns the same asSqlValidatorNamespace.getNode()
.- Specified by:
getEnclosingNode
in interfaceSqlValidatorNamespace
-
lookupChild
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
- Parameters:
name
- Name of namespace- Returns:
- Namespace
-
field
Description copied from interface:SqlValidatorNamespace
Returns a field of a given name, or null.- Specified by:
field
in interfaceSqlValidatorNamespace
- Parameters:
name
- Field name- Returns:
- Field, or null
-
getMustFilterFields
Description copied from interface:SqlValidatorNamespace
Returns the ordinals (in the row type) of the "must-filter" fields, fields that that must be filtered in a query.- Specified by:
getMustFilterFields
in interfaceSqlValidatorNamespace
-
makeNullable
public void makeNullable()- Specified by:
makeNullable
in interfaceSqlValidatorNamespace
-
translate
-
unwrap
Description copied from interface:SqlValidatorNamespace
Returns this namespace, or a wrapped namespace, cast to a particular class.- Specified by:
unwrap
in interfaceSqlValidatorNamespace
- Parameters:
clazz
- Desired type- Returns:
- This namespace cast to desired type
-
isWrapperFor
Description copied from interface:SqlValidatorNamespace
Returns whether this namespace implements a given interface, or wraps a class which does.- Specified by:
isWrapperFor
in interfaceSqlValidatorNamespace
- Parameters:
clazz
- Interface- Returns:
- Whether namespace implements given interface
-
convertToStruct
-
toStruct
Converts a type to a struct if it is not already.
-