public class SqlDataTypeSpec extends SqlNode
A SqlDataTypeSpec is immutable; once created, you cannot
change any of the fields.
We support the following data type expressions:
ROW(
foo NUMBER(5, 2) NOT NULL,
rec ROW(b BOOLEAN, i MyUDT NOT NULL))
Internally we use SqlRowTypeNameSpec to specify row data type name.
SqlBasicTypeNameSpec to specify basic sql data type name.
INT ARRAY;
VARCHAR(20) MULTISET;
INT ARRAY MULTISET;
Internally we use SqlCollectionTypeNameSpec to specify collection data type name.
SqlUserDefinedTypeNameSpec to specify user defined data type name.
EMPTY_ARRAY, pos| Constructor and Description |
|---|
SqlDataTypeSpec(SqlTypeNameSpec typeNameSpec,
SqlParserPos pos)
Creates a type specification representing a type.
|
SqlDataTypeSpec(SqlTypeNameSpec typeNameSpec,
@Nullable TimeZone timeZone,
@Nullable Boolean nullable,
SqlParserPos pos)
Creates a type specification representing a type, with time zone,
nullability and base type name specified.
|
SqlDataTypeSpec(SqlTypeNameSpec typeNameSpec,
@Nullable TimeZone timeZone,
SqlParserPos pos)
Creates a type specification representing a type, with time zone specified.
|
| Modifier and Type | Method and Description |
|---|---|
<R> R |
accept(SqlVisitor<R> visitor)
Accepts a generic visitor.
|
SqlNode |
clone(SqlParserPos pos)
Clones a SqlNode with a different position.
|
RelDataType |
deriveType(SqlValidator validator)
Converts this type specification to a
RelDataType. |
RelDataType |
deriveType(SqlValidator validator,
boolean nullable)
Converts this type specification to a
RelDataType. |
boolean |
equalsDeep(@Nullable SqlNode node,
Litmus litmus)
Returns whether this node is structurally equivalent to another node.
|
@Nullable SqlIdentifier |
getCollectionsTypeName() |
SqlDataTypeSpec |
getComponentTypeSpec()
Returns a new SqlDataTypeSpec corresponding to the component type if the
type spec is a collections type spec.
Collection types are ARRAY and MULTISET. |
SqlMonotonicity |
getMonotonicity(@Nullable SqlValidatorScope scope)
Returns whether expression is always ascending, descending or constant.
|
@Nullable Boolean |
getNullable() |
@Nullable TimeZone |
getTimeZone() |
SqlIdentifier |
getTypeName() |
SqlTypeNameSpec |
getTypeNameSpec() |
void |
unparse(SqlWriter writer,
int leftPrec,
int rightPrec)
Writes a SQL representation of this node to a writer.
|
void |
validate(SqlValidator validator,
SqlValidatorScope scope)
Validates this node.
|
SqlDataTypeSpec |
withNullable(Boolean nullable)
Returns a copy of this data type specification with a given
nullability.
|
SqlDataTypeSpec |
withNullable(Boolean nullable,
SqlParserPos pos)
Returns a copy of this data type specification with a given
nullability, extending the parser position.
|
clone, clone, cloneArray, equalDeep, equalDeep, equalsDeep, findValidOptions, getKind, getParserPosition, isA, toList, toList, toSqlString, toSqlString, toSqlString, toString, unparseWithParentheses, validateExprpublic SqlDataTypeSpec(SqlTypeNameSpec typeNameSpec, SqlParserPos pos)
typeNameSpec - The type name can be basic sql type, row type,
collections type and user defined typepublic SqlDataTypeSpec(SqlTypeNameSpec typeNameSpec, @Nullable TimeZone timeZone, SqlParserPos pos)
typeNameSpec - The type name can be basic sql type, row type,
collections type and user defined typetimeZone - Specified time zonepublic SqlDataTypeSpec(SqlTypeNameSpec typeNameSpec, @Nullable TimeZone timeZone, @Nullable Boolean nullable, SqlParserPos pos)
typeNameSpec - The type name can be basic sql type, row type,
collections type and user defined typetimeZone - Specified time zonenullable - The nullabilitypublic SqlNode clone(SqlParserPos pos)
SqlNodepublic SqlMonotonicity getMonotonicity(@Nullable SqlValidatorScope scope)
SqlNodeThe default implementation returns
SqlMonotonicity.NOT_MONOTONIC.
getMonotonicity in class SqlNodescope - Scopepublic @Nullable SqlIdentifier getCollectionsTypeName()
public SqlIdentifier getTypeName()
public SqlTypeNameSpec getTypeNameSpec()
public @Nullable TimeZone getTimeZone()
public @Nullable Boolean getNullable()
public SqlDataTypeSpec withNullable(Boolean nullable)
public SqlDataTypeSpec withNullable(Boolean nullable, SqlParserPos pos)
public SqlDataTypeSpec getComponentTypeSpec()
ARRAY and MULTISET.public void unparse(SqlWriter writer, int leftPrec, int rightPrec)
SqlNodeThe leftPrec and rightPrec parameters give
us enough context to decide whether we need to enclose the expression in
parentheses. For example, we need parentheses around "2 + 3" if preceded
by "5 *". This is because the precedence of the "*" operator is greater
than the precedence of the "+" operator.
The algorithm handles left- and right-associative operators by giving them slightly different left- and right-precedence.
If SqlWriter.isAlwaysUseParentheses() is true, we use
parentheses even when they are not required by the precedence rules.
For the details of this algorithm, see SqlCall.unparse(org.apache.calcite.sql.SqlWriter, int, int).
public void validate(SqlValidator validator, SqlValidatorScope scope)
SqlNodeThe typical implementation of this method will make a callback to the
validator appropriate to the node type and context. The validator has
methods such as SqlValidator.validateLiteral(org.apache.calcite.sql.SqlLiteral) for these purposes.
public <R> R accept(SqlVisitor<R> visitor)
SqlNodeImplementations of this method in subtypes simply call the appropriate
visit method on the
visitor object.
The type parameter R must be consistent with the type
parameter of the visitor.
public boolean equalsDeep(@Nullable SqlNode node, Litmus litmus)
SqlNodeequalsDeep in class SqlNodepublic RelDataType deriveType(SqlValidator validator)
RelDataType.
Throws an error if the type is not found.
public RelDataType deriveType(SqlValidator validator, boolean nullable)
RelDataType.
Throws an error if the type is not found.
nullable - Whether the type is nullable if the type specification
does not explicitly stateCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.