| Modifier and Type | Field and Description |
|---|---|
protected @Nullable com.google.common.collect.ImmutableList<SqlParserPos> |
componentPositions
A list of the positions of the components of compound identifiers.
|
com.google.common.collect.ImmutableList<String> |
names
Array of the components of this compound identifier.
|
static SqlIdentifier |
STAR
An identifier for star, "*".
|
EMPTY_ARRAY, pos| Constructor and Description |
|---|
SqlIdentifier(List<String> names,
@Nullable SqlCollation collation,
SqlParserPos pos,
@Nullable List<SqlParserPos> componentPositions)
Creates a compound identifier, for example
foo.bar. |
SqlIdentifier(List<String> names,
SqlParserPos pos) |
SqlIdentifier(String name,
@Nullable 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.
|
SqlIdentifier |
add(int i,
String name,
SqlParserPos pos)
Returns an identifier that is the same as this except with a component
added at a given position.
|
void |
assignNamesFrom(SqlIdentifier other)
Copies names and components from another identifier.
|
SqlNode |
clone(SqlParserPos pos)
Clones a SqlNode with a different position.
|
boolean |
equalsDeep(@Nullable SqlNode node,
Litmus litmus)
Returns whether this node is structurally equivalent to another node.
|
@Nullable 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(@Nullable SqlValidatorScope scope)
Returns whether expression is always ascending, descending or constant.
|
String |
getSimple() |
static String |
getString(List<String> names)
Converts a list of strings to a qualified identifier.
|
boolean |
isComponentQuoted(int i)
Returns whether the
ith component of a compound identifier is
quoted. |
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 |
plusStar()
Creates an identifier that consists of this identifier plus a wildcard star.
|
SqlIdentifier |
setName(int i,
String name)
Returns an identifier that is the same as this except one modified name.
|
void |
setNames(List<String> names,
@Nullable List<SqlParserPos> poses)
Modifies the components of this identifier and their positions.
|
static Iterable<String> |
simpleNames(Iterable<? extends SqlNode> list)
Returns the simple names in a iterable of identifiers.
|
static List<String> |
simpleNames(List<? extends SqlNode> list)
Returns the simple names in a list of identifiers.
|
SqlIdentifier |
skipLast(int n)
Creates an identifier that consists of all but the last
n
name segments of this one. |
static SqlIdentifier |
star(List<String> names,
SqlParserPos pos,
List<SqlParserPos> componentPositions)
Creates an identifier that ends in a wildcard star.
|
static SqlIdentifier |
star(SqlParserPos pos)
Creates an identifier that is a singleton wildcard star.
|
static List<String> |
toStar(List<String> names)
Converts empty strings in a list of names to stars.
|
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, clone, cloneArray, equalDeep, equalDeep, equalsDeep, findValidOptions, getParserPosition, isA, toList, toList, toSqlString, toSqlString, toSqlString, unparseWithParenthesespublic static final SqlIdentifier STAR
SqlNodeList.SINGLETON_STARpublic com.google.common.collect.ImmutableList<String> names
The empty string represents the wildcard "*", to distinguish it from a real "*" (presumably specified using quotes).
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.
protected @Nullable com.google.common.collect.ImmutableList<SqlParserPos> componentPositions
public SqlIdentifier(List<String> names, @Nullable SqlCollation collation, SqlParserPos pos, @Nullable List<SqlParserPos> componentPositions)
foo.bar.names - Parts of the identifier, length ≥ 1public SqlIdentifier(List<String> names, SqlParserPos pos)
public SqlIdentifier(String name, @Nullable SqlCollation collation, SqlParserPos pos)
foo, with a
collation.public SqlIdentifier(String name, SqlParserPos pos)
foo.public static SqlIdentifier star(SqlParserPos pos)
public static SqlIdentifier star(List<String> names, SqlParserPos pos, List<SqlParserPos> componentPositions)
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 static String getString(List<String> names)
public static List<String> toStar(List<String> names)
public void setNames(List<String> names, @Nullable List<SqlParserPos> poses)
names - Names of componentsposes - Positions of componentspublic SqlIdentifier setName(int i, String name)
public SqlIdentifier add(int i, String name, SqlParserPos pos)
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 plusStar()
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(@Nullable SqlNode node, Litmus litmus)
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.
@Pure public @Nullable SqlCollation getCollation()
public String getSimple()
public static List<String> simpleNames(List<? extends SqlNode> list)
public static Iterable<String> simpleNames(Iterable<? extends SqlNode> list)
public boolean isStar()
public boolean isSimple()
public boolean isComponentQuoted(int i)
ith component of a compound identifier is
quoted.i - Ordinal of componentpublic SqlMonotonicity getMonotonicity(@Nullable SqlValidatorScope scope)
SqlNodeThe default implementation returns
SqlMonotonicity.NOT_MONOTONIC.
getMonotonicity in class SqlNodescope - ScopeCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.