| Modifier and Type | Field and Description |
|---|---|
com.google.common.collect.ImmutableList<String> |
names
Array of the components of this compound identifier.
|
EMPTY_ARRAY, pos| Constructor and Description |
|---|
SqlIdentifier(List<String> names,
SqlCollation collation,
SqlParserPos pos,
List<SqlParserPos> componentPositions)
Creates a compound identifier, for example
foo.bar. |
SqlIdentifier(List<String> names,
SqlParserPos pos) |
SqlIdentifier(String name,
SqlCollation collation,
SqlParserPos pos)
Creates a simple identifier, for example
foo, with a
collation. |
SqlIdentifier(String name,
SqlParserPos pos)
Creates a simple identifier, for example
foo. |
| Modifier and Type | Method and Description |
|---|---|
<R> R |
accept(SqlVisitor<R> visitor)
Accepts a generic visitor.
|
void |
assignNamesFrom(SqlIdentifier other)
Copies names and components from another identifier.
|
SqlNode |
clone(SqlParserPos pos)
Clones a SqlNode with a different position.
|
boolean |
equalsDeep(SqlNode node,
boolean fail)
Returns whether this node is structurally equivalent to another node.
|
SqlCollation |
getCollation() |
SqlIdentifier |
getComponent(int ordinal)
Creates an identifier which contains only the
ordinalth
component of this compound identifier. |
SqlIdentifier |
getComponent(int from,
int to) |
SqlParserPos |
getComponentParserPosition(int i)
Returns the position of the
ith component of a compound
identifier, or the position of the whole identifier if that information
is not present. |
SqlKind |
getKind()
Returns the type of node this is, or
SqlKind.OTHER if it's nothing special. |
SqlMonotonicity |
getMonotonicity(SqlValidatorScope scope)
Returns whether expression is always ascending, descending or constant.
|
String |
getSimple() |
boolean |
isSimple()
Returns whether this is a simple identifier.
|
boolean |
isStar()
Returns whether this identifier is a star, such as "*" or "foo.bar.*".
|
SqlIdentifier |
plus(String name,
SqlParserPos pos)
Creates an identifier that consists of this identifier plus a name segment.
|
SqlIdentifier |
setName(int i,
String name)
Returns an identifier that is the same as this except one modified name.
|
void |
setNames(List<String> names,
List<SqlParserPos> poses)
Modifies the components of this identifier and their positions.
|
SqlIdentifier |
skipLast(int n)
Creates an identifier that consists of all but the last
n
name segments of this one. |
String |
toString() |
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.
|
void |
validateExpr(SqlValidator validator,
SqlValidatorScope scope)
Validates this node in an expression context.
|
clone, cloneArray, equalDeep, equalDeep, findValidOptions, getParserPosition, isA, toSqlString, toSqlStringpublic com.google.common.collect.ImmutableList<String> names
It's convenient to have this member public, and it's convenient to
have this member not-final, but it's a shame it's public and not-final.
If you assign to this member, please use
setNames(java.util.List, java.util.List).
And yes, we'd like to make identifiers immutable one day.
public SqlIdentifier(List<String> names, SqlCollation collation, SqlParserPos pos, List<SqlParserPos> componentPositions)
foo.bar.names - Parts of the identifier, length ≥ 1public SqlIdentifier(List<String> names, SqlParserPos pos)
public SqlIdentifier(String name, SqlCollation collation, SqlParserPos pos)
foo, with a
collation.public SqlIdentifier(String name, SqlParserPos pos)
foo.public SqlKind getKind()
SqlNodeSqlKind.OTHER if it's nothing special.getKind in class SqlNodeSqlKind value, never nullSqlNode.isA(java.util.Set<org.apache.calcite.sql.SqlKind>)public SqlNode clone(SqlParserPos pos)
SqlNodepublic void setNames(List<String> names, List<SqlParserPos> poses)
names - Names of componentsposes - Positions of componentspublic SqlIdentifier setName(int i, String name)
public SqlParserPos getComponentParserPosition(int i)
ith component of a compound
identifier, or the position of the whole identifier if that information
is not present.i - Ordinal of component.public void assignNamesFrom(SqlIdentifier other)
other - identifier from which to copypublic SqlIdentifier getComponent(int ordinal)
ordinalth
component of this compound identifier. It will have the correct
SqlParserPos, provided that detailed position information is
available.public SqlIdentifier getComponent(int from, int to)
public SqlIdentifier plus(String name, SqlParserPos pos)
public SqlIdentifier skipLast(int n)
n
name segments of this one.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 void validateExpr(SqlValidator validator, SqlValidatorScope scope)
SqlNodeUsually, this method does much the same as SqlNode.validate(org.apache.calcite.sql.validate.SqlValidator, org.apache.calcite.sql.validate.SqlValidatorScope), but a
SqlIdentifier can occur in expression and non-expression
contexts.
validateExpr in class SqlNodepublic boolean equalsDeep(SqlNode node, boolean fail)
SqlNodeequalsDeep in class SqlNodepublic <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 SqlCollation getCollation()
public String getSimple()
public boolean isStar()
public boolean isSimple()
public SqlMonotonicity getMonotonicity(SqlValidatorScope scope)
SqlNodeThe default implementation returns
SqlMonotonicity.NOT_MONOTONIC.
getMonotonicity in class SqlNodeCopyright © 2012–2015 The Apache Software Foundation. All rights reserved.