public class SqlDataTypeSpec extends SqlNode
A SqlDataTypeSpec is immutable; once created, you cannot
change any of the fields.
todo: This should really be a subtype of SqlCall.
In its full glory, we will have to support complex type expressions like:
ROW(
NUMBER(5, 2) NOT NULL AS foo,
ROW(BOOLEAN AS b, MyUDT NOT NULL AS i) AS rec)
Currently it only supports simple datatypes like CHAR, VARCHAR and DOUBLE, with optional precision and scale.
EMPTY_ARRAY, pos| Constructor and Description |
|---|
SqlDataTypeSpec(SqlIdentifier typeName,
int precision,
int scale,
String charSetName,
TimeZone timeZone,
SqlParserPos pos)
Creates a type specification representing a regular, non-collection type.
|
SqlDataTypeSpec(SqlIdentifier collectionsTypeName,
SqlIdentifier typeName,
int precision,
int scale,
String charSetName,
SqlParserPos pos)
Creates a type specification representing a collection type.
|
SqlDataTypeSpec(SqlIdentifier collectionsTypeName,
SqlIdentifier typeName,
int precision,
int scale,
String charSetName,
TimeZone timeZone,
Boolean nullable,
SqlParserPos pos)
Creates a type specification.
|
| 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(RelDataTypeFactory typeFactory)
Does not throw an error if the type is not built-in.
|
RelDataType |
deriveType(SqlValidator validator)
Throws an error if the type is not built-in.
|
boolean |
equalsDeep(SqlNode node,
boolean fail)
Returns whether this node is structurally equivalent to another node.
|
String |
getCharSetName() |
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(SqlValidatorScope scope)
Returns whether expression is always ascending, descending or constant.
|
int |
getPrecision() |
int |
getScale() |
TimeZone |
getTimeZone() |
SqlIdentifier |
getTypeName() |
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.
|
clone, cloneArray, equalDeep, equalDeep, findValidOptions, getKind, getParserPosition, isA, toSqlString, toSqlString, toString, validateExprpublic SqlDataTypeSpec(SqlIdentifier typeName, int precision, int scale, String charSetName, TimeZone timeZone, SqlParserPos pos)
public SqlDataTypeSpec(SqlIdentifier collectionsTypeName, SqlIdentifier typeName, int precision, int scale, String charSetName, SqlParserPos pos)
public SqlDataTypeSpec(SqlIdentifier collectionsTypeName, SqlIdentifier typeName, int precision, int scale, String charSetName, TimeZone timeZone, Boolean nullable, SqlParserPos pos)
public SqlNode clone(SqlParserPos pos)
SqlNodepublic SqlMonotonicity getMonotonicity(SqlValidatorScope scope)
SqlNodeThe default implementation returns
SqlMonotonicity.NOT_MONOTONIC.
getMonotonicity in class SqlNodepublic SqlIdentifier getCollectionsTypeName()
public SqlIdentifier getTypeName()
public int getScale()
public int getPrecision()
public String getCharSetName()
public TimeZone getTimeZone()
public SqlDataTypeSpec withNullable(Boolean nullable)
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(SqlNode node, boolean fail)
SqlNodeequalsDeep in class SqlNodepublic RelDataType deriveType(SqlValidator validator)
public RelDataType deriveType(RelDataTypeFactory typeFactory)
Copyright © 2012–2015 The Apache Software Foundation. All rights reserved.