public class TObjectName extends TParseTreeNode implements Cloneable
The general syntax of database object in Oracle: [schema.]object[.part][@dblink]
The general syntax of database object in SQL Server: [server.][database.][schema.]object
The meaning of getObjectToken() and getPartToken() depends on the getDbObjectType().
If this database object is a schema object such as table, index, then the objectToken represents this
database object and partToken is null.
If this TObjectName represents a column, the partToken represents the column name, the objectToken is table/view
name of this column if this column is qualified like table.column, otherwise, the objectToken is
null.
schemaToken, databaseToken, serverToken is the qualified part of a database object name.
If this objectName represents a database name in the create database statement like this
CREATE DATABASE menagerie, then, the objectToken is menagerie and databaseToken is null.
EDbObjectType| Modifier and Type | Field and Description |
|---|---|
int |
searchLevel
Internal use only
|
static int |
ttobjAttribute
Deprecated.
replaced by
EDbObjectType.
attribute name is in partToken |
static int |
ttobjColumn
Deprecated.
replaced by
EDbObjectType.
column in table, objectToken is table if specified, and partToken is column name. |
static int |
ttobjColumnAlias
Deprecated.
replaced by
EDbObjectType.
column alias in objectToken. |
static int |
ttobjColumnMethod
Deprecated.
replaced by
EDbObjectType.method.
column method like SetXY below, column method in methodToken, and colomn name in partToken.
UPDATE Cities SET Location.SetXY(23.5, 23.5) |
static int |
ttobjConstraintName
Deprecated.
replaced by
EDbObjectType.constraint.
constraint name in objectToken |
static int |
ttobjDatatype
Deprecated.
replaced by
EDbObjectType.
datatype was not represented by a TObjectName object, this constant was used in source tokens that consist of TTypeName. |
static int |
ttobjFunctionName
Deprecated.
replaced by
EDbObjectType.
function name in objectToken |
static int |
ttobjLambdaParameter
Lambda parameter, at its declaration and at every use in the lambda body.
|
static int |
ttobjNamedArgParameter
Named argument parameter name in function calls.
|
static int |
ttobjNotAObject
Deprecated.
replaced by
EDbObjectType.
this is not an object, like sysdate function in oracle database |
static int |
ttobjParameter
Deprecated.
replaced by
EDbObjectType.
parameter name in objectToken. |
static int |
ttobjPositionalParameters
Deprecated.
replaced by
EDbObjectType.
postgresql
Positional Parameters, $1, $1[1], $1[1,10]
parameter name is in partToken of $1,
and parameter name is in objectToken of $1.columnName,
and column name is in partToken |
static int |
ttobjSchemaName
Deprecated.
replaced by
EDbObjectType.
schema name in schemaToken |
static int |
ttobjStringConstant
Deprecated.
replaced by
EDbObjectType.
string constant in objectToken |
static int |
ttobjTable
Deprecated.
replaced by
EDbObjectType.
table name in objectToken. |
static int |
ttobjUnknown
Deprecated.
replaced by
EDbObjectType.
object type can't be determined. |
static int |
ttobjVariable
Deprecated.
replaced by
EDbObjectType.
variable name in objectToken. |
dbvendor, doubleLinkedTokenListToString, nodeActionAppend, nodeActionInsert, nodeActionRemove, nodeActionUnknown, nodeActionUpdate, nodeActionUpdateText, nodeChangeEndToken, nodeChangeStartToken| Constructor and Description |
|---|
TObjectName() |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(TParseTreeVisitor v)
Accept a visitor
|
void |
acceptChildren(TParseTreeVisitor v)
Accept a visitor to iterate this class and sub-nodes of this class
|
void |
appendObjectName(TObjectName objectName) |
void |
attributesToPropertyToken(TObjectNameList attributes)
used in Oracle and teradata SQL syntax
|
void |
clearCandidateTables()
Drop every candidate table recorded for this reference.
|
TObjectName |
clone() |
void |
columnToFieldPath(int fieldCount)
Re-read this column name as a column followed by
fieldCount fields of its value, counted from the end of
getIdentifierChain(): the part before the fields becomes the column token, the first field the
property token, and the parts before the column its qualifier. |
void |
columnToProperty() |
void |
columnToPropertyIfQualifiedByTable(TTable pBoundTable)
Apply the qualifier rule of
resolveWithThisTable(TTable) to a column that is
bound to pBoundTable by its position rather than found by a name lookup. |
String |
coordinate()
The X and Y position of this objectName in the SQL
|
static TObjectName |
createObjectName(EDbVendor dbVendor,
EDbObjectType dbObjectType) |
static TObjectName |
createObjectName(EDbVendor dbVendor,
EDbObjectType dbObjectType,
String str) |
static TObjectName |
createObjectName(EDbVendor dbVendor,
EDbObjectType dbObjectType,
TSourceToken token1) |
static TObjectName |
createObjectName(EDbVendor dbVendor,
EDbObjectType dbObjectType,
TSourceToken token1,
TSourceToken token2) |
static TObjectName |
createObjectName(EDbVendor dbVendor,
EDbObjectType dbObjectType,
TSourceToken token1,
TSourceToken token2,
TSourceToken token3) |
static TObjectName |
createObjectName(EDbVendor dbVendor,
EDbObjectType dbObjectType,
TSourceToken token1,
TSourceToken token2,
TSourceToken token3,
TSourceToken token4) |
List<TSourceToken> |
getAdditionalParts()
Get additional parts beyond the standard 6 tokens.
|
String |
getAnsiCatalogName()
If a table name is not qualified with a database name, but GSP detect the database for this table in the metadata
then, this method will return this detected database name.
|
String |
getAnsiSchemaName()
In this SQL: select * from part1.part2,
In Hive, MySQL and Teradata, part1 will be treated as a database name, returned in getDatabaseString(),
while getSchemaString() return empty string.
|
TSourceToken |
getAtsign() |
ArrayList<TAttributeNode> |
getAttributeNodesDerivedFromFromClause()
这个属性只有当 column 为 * 时有效
当 column 为 * 时, 本属性包含该 * 展开后对应的 attributeNode 列表,来源是 FROM CLAUSE中的 tables, 在 resolve star column
时给本属性赋值, TStmtScope.resolve(TObjectName objectName)
当 table 有metadata或DDL给出了明确的字段时,每table个展开的 attributeNode 包含明确的字段名,such as t.c
当 table 没有 metadata 和 DDL 时,每table个只展开的 一个 attributeNode,内容为 t.*
|
ArrayList<TColumnTableMatch> |
getCandidateAttributeNodes()
非 star column 使用该属性存放可能包含该 column 的 attributeNode
star column 使用
getAttributeNodesDerivedFromFromClause() |
Map<TTable,Integer> |
getCandidateTableDdlStatus()
Get DDL verification status for all candidate tables.
|
TTableList |
getCandidateTables() |
List<TTable> |
getCandidateTables2()
Get all candidate tables (for ambiguous columns)
|
TObjectNameList |
getColumnAttributes()
The data type of this column is structured UDT, this method returns the column's attributes.
|
String |
getColumnNameOnly()
Returns only the column name if it's prefixed with a table name
|
long |
getColumnNo()
The column position of this objectName in the SQL
|
TResultColumnList |
getColumnsLinkedToStar()
if this is a star column(column name is *), and the value of this star column
is derived from a subquery, then, this field points to the select list in the subquery
|
ArrayList<String> |
getColumnsLinkedToStarColumn() |
ColumnSource |
getColumnSource()
Convenience method: get column source (most common access pattern)
|
TSourceToken |
getColumnToken()
|
TSourceToken |
getCommentString() |
String |
getDatabaseString()
String text of the database name
|
TSourceToken |
getDatabaseToken()
The database part of this objectName: [server.][database.][schema.]object
|
TObjectName |
getDblink()
The database link part
remoreserver in this objectName: scott.emp@remoreserver |
EDbObjectType |
getDbObjectType()
The database object type of this objectName such as table, view, column for example.
|
int |
getDdlVerificationStatus(TTable table)
Check DDL verification status for a candidate table.
|
TExceptReplaceClause |
getExceptReplaceClause() |
TSourceToken |
getExclamationmark() |
TCTE |
getExpressionCteRef()
ClickHouse: when this unqualified column reference is actually the alias
of an expression-CTE (
WITH <expr> AS ident), the CTE it refers
to; null otherwise. |
TSourceToken |
getFieldPathBaseToken()
The token of the column whose field
getFieldPathRead() reads, such as customer in
o.customer.address.city; null when the reference reads a whole column. |
StructuredColumnPath |
getFieldPathRead()
The STRUCT field path this column reference reads below its column, as written: the column it reads into,
then each field and array element after it.
|
List<TSourceToken> |
getIdentifierChain()
The identifiers this name is written with, in order, up to its first subscript.
|
IdentifierInputForm |
getImplictDatabaseForm()
Where the text of
getImplictDatabaseString() came from; see getImplictSchemaForm(). |
String |
getImplictDatabaseString() |
IdentifierInputForm |
getImplictSchemaForm()
Where the text of
getImplictSchemaString() came from, so a consumer can key it:
IdentifierInputForm.CATALOG_STORED when the name was found by
searching the catalog and the text is the schema the catalog holds it in (TSQLSchema.getName()),
IdentifierInputForm.SQL_LEXICAL when it is a spelling: the name's
own qualifier, or a session default a resolver stamped, which the catalog itself reads as SQL. |
String |
getImplictSchemaString()
This is the schema fetched from the SQLEnv.
|
TIndirection |
getIndirection() |
long |
getLineNo()
The line number of this objectName in SQL
|
TColumnDefinition |
getLinkedColumnDef()
The column definition in create/alter table statement that include this column name object.
|
gudusoft.gsqlparser.compiler.TVariable |
getLinkedVariable() |
TSourceToken |
getMethodToken() |
TObjectName |
getNamespace()
The Couchbase namespace before keyspace
|
NestedAccess |
getNestedAccess()
|
NestedAccessSyntax |
getNestedAccessSyntax()
The syntax of this name for the nested-access normalizer: the identifier chain, the chain before a trailing
wildcard and the indirection, read from the name as it is now.
|
NestedAccess |
getNestedStarAccess()
|
String |
getNormalizedColumnString()
Get normalized column string with caching (Phase 5 optimization).
|
String |
getNormalizedDatabaseString()
Get normalized database string with caching (Phase 5 optimization).
|
String |
getNormalizedSchemaString()
Get normalized schema string with caching (Phase 5 optimization).
|
String |
getNormalizedServerString()
Get normalized server string with caching (Phase 5 optimization).
|
String |
getNormalizedTableString()
Get normalized table string with caching (Phase 5 optimization).
|
int |
getNumberOfPart()
List the number of parts made up this objectName
|
String |
getObjectString()
String text of the object name
|
TSourceToken |
getObjectToken()
The object part of this objectName such as table name, view name.
|
int |
getObjectType()
Deprecated.
use
getDbObjectType() instead. |
TCustomSqlStatement |
getOwnStmt() |
String |
getPackageString()
String text of the package name.
|
TSourceToken |
getPackageToken()
Oracle package name
|
TObjectName |
getParentObjectName() |
String |
getPartString()
String text of the part name
|
TSourceToken |
getPartToken()
The column name of this objectName if
getDbObjectType() is EDbObjectType.column. |
TPathSqlNode |
getPath()
stage path
|
TSourceToken |
getPropertyToken() |
EPseudoTableType |
getPseudoTableType() |
EQuoteType |
getQuoteType()
Tell whether this is a quoted objectName.
|
TObjectNameList |
getReferencedObjects() |
ResolutionResult |
getResolution()
Get resolution result from new resolver
|
int |
getResolveStatus() |
String |
getSchemaString()
String text of schema name in a qualified name of a schema object.
|
TSourceToken |
getSchemaToken()
The schema name of this objectName.
|
String |
getServerString()
String text of the server name
|
TSourceToken |
getServerToken()
The server part of this objectName: [server.][database.][schema.]object
|
TAttributeNode |
getSourceAttributeNode()
Deprecated.
Since 3.4.0.5. Use TSQLResolver2 with
getResolution() instead. |
TResultColumn |
getSourceColumn() |
TTable |
getSourceTable()
Get the immediate source table where this column is visible in the current scope.
|
ArrayList<TTable> |
getSourceTableList()
source table list for star column,
select * from emp,dept * column will be list to both emp and dept table. |
List<TSourceToken> |
getStarQualifierChain()
The identifiers before the wildcard of a name that ends with one, as written:
e.payload.* gives
e, payload, BigQuery customer.address.* gives customer, address. |
StructFieldHint |
getStructFieldHint()
Get the struct field hint for deep struct access (3+ part names without alias).
|
TSourceToken |
getStructStarBaseToken()
The token of the column
getStructStarPath() starts at; null when that is null. |
StructuredColumnPath |
getStructStarPath()
The STRUCT column or field whose fields a wildcard below it reads, as written: BigQuery
customer.* reads
every field of customer, customer.address.* every field of customer.address, and
Athena e.payload.* every field of payload. |
List<TExpression> |
getSubscriptExpressions()
The expressions inside the subscripts of this name,
arr[n], payload.items[idx].name: column
references that TSQLResolver2 and the lineage analyzer read like any other (Mantis 4817). |
ETableKind |
getTableKind() |
String |
getTableString()
String text of the table name.
|
TSourceToken |
getTableToken()
The table name of this objectName, it's the same value as
getObjectToken() if getDbObjectType()
is EDbObjectType.table |
int |
getValidate_column_status() |
void |
init(EDbObjectType dbObjectType,
Object arg1,
Object arg2,
Object arg3) |
void |
init(Object arg1)
Initialize a query tree node.
|
void |
init(Object arg1,
Object arg2) |
void |
init(Object arg1,
Object arg2,
Object arg3) |
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4) |
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5) |
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5,
Object arg6) |
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5,
Object arg6,
Object arg7)
Init with 7 tokens for deeply nested struct field access (e.g., BigQuery)
Pattern: a.b.c.d.e.f.g (7 parts)
|
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5,
Object arg6,
Object arg7,
Object arg8)
Init with 8 tokens for deeply nested struct field access
Pattern: a.b.c.d.e.f.g.h (8 parts)
|
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5,
Object arg6,
Object arg7,
Object arg8,
Object arg9)
Init with 9 tokens for deeply nested struct field access
Pattern: a.b.c.d.e.f.g.h.i (9 parts)
|
void |
init(Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5,
Object arg6,
Object arg7,
Object arg8,
Object arg9,
Object arg10)
Init with 10 tokens for deeply nested struct field access
Pattern: a.b.c.d.e.f.g.h.i.j (10 parts)
|
boolean |
isAmbiguous()
Check if this column reference is ambiguous
|
boolean |
isAttributeNameInObjectName(TSourceToken leftparen,
TSourceToken rightparen) |
boolean |
isCandidatesFromUnion()
Returns true if candidate tables came from UNION/CTE branch propagation,
false if they came from ambiguity (e.g., unqualified column in multi-table query).
|
boolean |
isColumnOnly()
Whether its position takes a column name only, so a variable or parameter of the same name is never read there:
the argument of MySQL
VALUES(col) and DEFAULT(col). |
boolean |
isContinueToSearch() |
boolean |
isImplicitDatabase() |
boolean |
isImplicitSchema() |
boolean |
isOrphanColumn() |
boolean |
isQualified()
Check whether a column is prefixed by a table like this:
table.column |
boolean |
isReservedKeyword() |
boolean |
isResolved()
Check if this column reference has been resolved (by new resolver)
|
boolean |
isSubscripts()
PostgreSQL column with array types
|
boolean |
isTableDetermined()
Sometime, a non-qualified column can't be linked to a table without additional metadata from database.
|
boolean |
isValidColumnName(EDbVendor pDBVendor)
Check whether a column name is syntax valid in a specific database vendor.
|
void |
mergeObjectName(TObjectName objectName)
Used internally in hive .y file to merge two objectNames
|
void |
mergeObjectName(TObjectName objectName,
TObjectName objectName2) |
boolean |
resolveWithThisTable(TTable pTable)
This column must be in this syntax: table.column, otherwise, this method always return false.
|
protected TSQLSchema |
searchImplicitSchema() |
void |
setAtsign(TSourceToken atsign) |
void |
setColumnAttributes(TObjectNameList columnAttributes) |
void |
setColumnOnly(boolean columnOnly) |
void |
setColumnsLinkedToStar(TResultColumnList columnsLinkedToStar) |
void |
setCommentString(TSourceToken commentString) |
void |
setDatabaseToken(TSourceToken databaseToken) |
void |
setDatabaseToken(TSourceToken databaseToken,
boolean implicit) |
void |
setDblink(TObjectName dblink) |
void |
setDblink(TObjectName dblink,
boolean linkToDB) |
void |
setDbObjectType(EDbObjectType dbObjectType)
Set object type of this objectName
|
void |
setDbObjectType(EDbVendor dbVendor,
EDbObjectType dbObjectType) |
void |
setDbObjectTypeDirectly(EDbObjectType dbObjectType) |
void |
setExceptReplaceClause(TExceptReplaceClause exceptReplaceClause) |
void |
setExclamationmark(TSourceToken exclamationmark) |
void |
setExpressionCteRef(TCTE expressionCteRef) |
void |
setImplictDatabaseName(String implictDatabaseName) |
void |
setImplictSchemaName(String implictSchemaName) |
void |
setIndirection(TIndirection indirection) |
void |
setLinkedColumnDef(TColumnDefinition linkedColumnDef) |
void |
setLinkedVariable(gudusoft.gsqlparser.compiler.TVariable linkedVariable) |
void |
setMethodToken(TSourceToken methodToken) |
void |
setNamespace(TObjectName namespace) |
void |
setObjectToken(TSourceToken objectToken) |
void |
setObjectType(int objectType)
Deprecated.
|
void |
setOrphanColumn(boolean orphanColumn) |
void |
setOwnStmt(TCustomSqlStatement ownStmt) |
void |
setPackageToken(TSourceToken packageToken) |
void |
setParentObjectName(TObjectName parentObjectName) |
void |
setPartToken(TSourceToken partToken) |
void |
setPath(TPathSqlNode path) |
void |
setPropertyToken(TSourceToken propertyToken) |
void |
setPseudoTableType(EPseudoTableType pseudoTableType) |
void |
setQuoteType(EQuoteType quoteType) |
void |
setResolution(ResolutionResult resolution)
Set resolution result (called by resolver2.NameResolver)
|
void |
setResolveStatus(int resolveStatus) |
void |
setSchemaToken(TSourceToken schemaToken) |
void |
setSchemaToken(TSourceToken schemaToken,
boolean implicit) |
void |
setServerToken(TSourceToken serverToken) |
void |
setSourceAttributeNode(TAttributeNode sourceAttributeNode)
Deprecated.
Since 3.4.0.5. Use TSQLResolver2 with
setResolution(gudusoft.gsqlparser.resolver2.model.ResolutionResult) instead. |
void |
setSourceColumn(TResultColumn sourceColumn)
Set the result column which include this column name.
|
void |
setSourceColumnOnly(TResultColumn sourceColumn)
Set the source column without changing dbObjectType.
|
void |
setSourceTable(TTable sourceTable)
Set the table this column belongs to.
|
void |
setSourceTableBySQLResolver(TCustomSqlStatement sqlStatement,
TAttributeNode attributeNode,
TTable newSourceTable) |
void |
setSqlEnv(TSQLEnv sqlEnv) |
void |
setStructFieldHint(StructFieldHint hint)
Set the struct field hint (called by NameResolver for 3+ part no-alias struct patterns).
|
void |
setTableDetermined(boolean tableDetermined) |
void |
setTableKind(ETableKind tableKind) |
void |
setValidate_column_status(int validate_column_status) |
void |
splitNameInQuotedIdentifier() |
void |
TObjectName() |
String |
toString()
返回该对象名的字符串表示(中文说明):
|
addAllMyTokensToTokenList, addToTokenChain, appendNewNode, calculateTokenCount, commentBlockAfter, commentBlockEndAfter, doAppendNewNode, doParse, fastSetString, getAnchorNode, getCommentAfterNode, getCommentBeforeNode, getCommentBeforeNode, getCommentBeforeNode, getCompactString, getDummyTag, getEndToken, getEvaluateDatatype, getEvalValue, getGsqlparser, getLocation, getMd5, getNodeStatus, getNodeType, getPlainText, getStartToken, getTokenCount, hasNext, insertAfterAToken, insertNewNodeBeforeMe, isChanged, isTokensInChain, next, refreshAllNodesTokenCount, remove, removeAllMyTokensFromTokenList, removeTokens, removeTokensBetweenNodes, removeTokensBetweenToken, replaceWithNewNode, resetIterator, setAnchorNode, setChanged, setDummyTag, setEndToken, setEndToken, setEndToken, setEndToken, setEndToken, setEndTokenDirectly, setEvaluateDatatype, setEvalValue, setGsqlparser, setIncludingComment, setLocation, setNewSubNode, setNodeStatus, setNodeType, setParent, setPlainText, setStartToken, setStartToken, setStartToken, setStartToken, setStartTokenDirectly, setString, setString2, subNodeInNode, toScript, toString2equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEachRemainingpublic int searchLevel
public static final int ttobjNotAObject
EDbObjectType.
this is not an object, like sysdate function in oracle databasepublic static final int ttobjUnknown
EDbObjectType.
object type can't be determined.public static final int ttobjColumn
EDbObjectType.
column in table, objectToken is table if specified, and partToken is column name.public static final int ttobjColumnAlias
EDbObjectType.
column alias in objectToken.public static final int ttobjTable
EDbObjectType.
table name in objectToken.public static final int ttobjParameter
EDbObjectType.
parameter name in objectToken.public static final int ttobjVariable
EDbObjectType.
variable name in objectToken.public static final int ttobjColumnMethod
EDbObjectType.method.
column method like SetXY below, column method in methodToken, and colomn name in partToken.
UPDATE Cities
SET Location.SetXY(23.5, 23.5)
public static final int ttobjNamedArgParameter
Example: In Snowflake FLATTEN(INPUT => parse_json(col), outer => TRUE), "INPUT" and "outer" are named argument parameter names, NOT column references.
These should be skipped during column resolution and data lineage analysis.
public static final int ttobjLambdaParameter
Example: in Trino/Athena filter(arr, (x) -> x <> '') or Databricks
transform(arr, x -> x + 1), both occurrences of x are lambda parameters,
NOT column references. TSQLResolver2 sets this marker; data lineage skips such names so a
lambda parameter never becomes an orphan column (Mantis 4805).
public static final int ttobjFunctionName
EDbObjectType.
function name in objectTokenpublic static final int ttobjConstraintName
EDbObjectType.constraint.
constraint name in objectTokenpublic static final int ttobjStringConstant
EDbObjectType.
string constant in objectTokenpublic static final int ttobjAttribute
EDbObjectType.
attribute name is in partTokenpublic static final int ttobjDatatype
EDbObjectType.
datatype was not represented by a TObjectName object, this constant was used in source tokens that consist of TTypeName.public static final int ttobjSchemaName
EDbObjectType.
schema name in schemaTokenpublic static final int ttobjPositionalParameters
EDbObjectType.
postgresql
Positional Parameters, $1, $1[1], $1[1,10]
parameter name is in partToken of $1,
and parameter name is in objectToken of $1.columnName,
and column name is in partTokenpublic TObjectName()
public void setOwnStmt(TCustomSqlStatement ownStmt)
public TCustomSqlStatement getOwnStmt()
public TExceptReplaceClause getExceptReplaceClause()
public void setExceptReplaceClause(TExceptReplaceClause exceptReplaceClause)
public void setTableKind(ETableKind tableKind)
public ETableKind getTableKind()
public EPseudoTableType getPseudoTableType()
public void setPseudoTableType(EPseudoTableType pseudoTableType)
public void setLinkedVariable(gudusoft.gsqlparser.compiler.TVariable linkedVariable)
public gudusoft.gsqlparser.compiler.TVariable getLinkedVariable()
@Deprecated public void setSourceAttributeNode(TAttributeNode sourceAttributeNode)
setResolution(gudusoft.gsqlparser.resolver2.model.ResolutionResult) instead.
This method is used only by the legacy TSQLResolver (RESOLVER).
It is not used when using TSQLResolver2 (RESOLVER2) for name resolution.
For RESOLVER2, use setResolution(gudusoft.gsqlparser.resolver2.model.ResolutionResult) instead.
sourceAttributeNode - the attribute node representing the resolved source@Deprecated public TAttributeNode getSourceAttributeNode()
getResolution() instead.
This method is used only by the legacy TSQLResolver (RESOLVER).
It is not used when using TSQLResolver2 (RESOLVER2) for name resolution.
For RESOLVER2, use getResolution() instead.
public NestedAccessSyntax getNestedAccessSyntax()
It is read afresh on every call, never cached: the name slots, tokens and indirection are public and mutable,
and the resolver's re-slotting (columnToFieldPath(int), columnToProperty()) keeps the chain they read
(pinned by TestNestedAccessNormalizer.aReResolvedNameKeepsItsPath).
public NestedAccess getNestedAccess()
public NestedAccess getNestedStarAccess()
public void setResolution(ResolutionResult resolution)
public ResolutionResult getResolution()
public ColumnSource getColumnSource()
public StructFieldHint getStructFieldHint()
public void setStructFieldHint(StructFieldHint hint)
public boolean isAmbiguous()
public boolean isResolved()
public List<TTable> getCandidateTables2()
public TObjectName clone()
public void setParentObjectName(TObjectName parentObjectName)
public TObjectName getParentObjectName()
getParentObjectName in class TParseTreeNodepublic void setPath(TPathSqlNode path)
public TPathSqlNode getPath()
public ArrayList<TTable> getSourceTableList()
public boolean isImplicitSchema()
public boolean isImplicitDatabase()
public ArrayList<TAttributeNode> getAttributeNodesDerivedFromFromClause()
public ArrayList<TColumnTableMatch> getCandidateAttributeNodes()
getAttributeNodesDerivedFromFromClause()public TTableList getCandidateTables()
public boolean isCandidatesFromUnion()
public void clearCandidateTables()
Needed when a reference is RE-BOUND away from the FROM-clause tables — a
WHERE reference corrected to a SELECT-list alias, for example. Clearing
sourceTable alone leaves the old candidates readable through
getCandidateTables(), so a consumer reading candidates would still
publish tables the reference does not name (MantisBT 4659).
public int getDdlVerificationStatus(TTable table)
Returns a tri-state result:
table - The candidate table to checkpublic Map<TTable,Integer> getCandidateTableDdlStatus()
Returns a map from each candidate table to its DDL verification status:
public void setOrphanColumn(boolean orphanColumn)
public boolean isOrphanColumn()
public boolean isColumnOnly()
VALUES(col) and DEFAULT(col).public void setColumnOnly(boolean columnOnly)
public boolean isReservedKeyword()
public void setLinkedColumnDef(TColumnDefinition linkedColumnDef)
public TColumnDefinition getLinkedColumnDef()
CREATE TABLE table_name (
column1 datatype,
column2 datatype
);
In above SQL, column1 datatype is the column definition while column1 is this
object name.public void setNamespace(TObjectName namespace)
public TObjectName getNamespace()
public String toString()
1) 优先调用父类 Object.toString() 获取已构造好的整体标识文本;
若父类返回非空,则:
- 对于 Snowflake,当 token 构成 IDENTIFIER(...) 形式时,仅提取并返回其中的
字面量部分(去除引号),以符合 Snowflake 标识符解析规则;
- 其他情况直接返回父类结果。
2) 若父类返回为空(尚未生成整体文本),则回退到更细粒度的 token:
- 若存在 part 级 token,返回其字符串;
- 否则若存在 object 级 token,返回其字符串;
- 若仍不存在,返回 null。
目的:统一并优先复用已构造的字符串表示,同时兼容特定数据库(如 Snowflake)的 标识符语义,从而在不同厂商 SQL 中提供稳定、符合预期的对象名输出。
toString in class TParseTreeNodepublic void setQuoteType(EQuoteType quoteType)
public EQuoteType getQuoteType()
public boolean isContinueToSearch()
public void setSourceColumn(TResultColumn sourceColumn)
sourceColumn - the result column includes this column namepublic void setSourceColumnOnly(TResultColumn sourceColumn)
sourceColumn - the result column includes this column namepublic TCTE getExpressionCteRef()
WITH <expr> AS ident), the CTE it refers
to; null otherwise. Such a reference names a scalar expression, not a
column of any table — getSourceTable() is intentionally null.public void setExpressionCteRef(TCTE expressionCteRef)
public TResultColumn getSourceColumn()
public boolean resolveWithThisTable(TTable pTable)
pTable - table used to match getTableToken() of this column objectpublic void columnToPropertyIfQualifiedByTable(TTable pBoundTable)
resolveWithThisTable(TTable) to a column that is
bound to pBoundTable by its position rather than found by a name lookup.
The grammar splits every three-part name as schema.table.column. A column found
by name lookup passes through resolveWithThisTable(TTable), which re-reads
alias.column.attribute as column plus getPropertyToken() once the head
turns out to name the table. A DML target column, such as the left-hand side of an
UPDATE or MERGE SET or an INSERT or MERGE INSERT column list, belongs to the
target table because of where it stands, so it never reached that lookup. It kept the
target's alias as its schema and the object column as its table: Oracle
UPDATE SET tgt.objcol.attr = v was reported as column attr of a table
objcol in a schema tgt (Mantis #4747).
This method delegates to resolveWithThisTable(TTable) so that both kinds of
binding split a name by the same rule. The match result is not needed: the caller has
already bound the column to pBoundTable.
pBoundTable - the table this column is bound to by its position, may be nullpublic boolean isQualified()
table.columntable.columnpublic int getValidate_column_status()
public void setValidate_column_status(int validate_column_status)
public boolean isValidColumnName(EDbVendor pDBVendor)
rowid is not a valid column name.pDBVendor - in which the database vendor the syntax of this column is checkedpublic ArrayList<String> getColumnsLinkedToStarColumn()
public void setColumnsLinkedToStar(TResultColumnList columnsLinkedToStar)
public TResultColumnList getColumnsLinkedToStar()
public void setSourceTable(TTable sourceTable)
sourceTable - table contains this columnpublic void setSourceTableBySQLResolver(TCustomSqlStatement sqlStatement, TAttributeNode attributeNode, TTable newSourceTable)
public TTable getSourceTable()
This returns the table/subquery/CTE that directly exposes this column in the FROM clause, NOT the final physical table after tracing through subqueries or CTEs.
To get the final physical table (after tracing through all layers), use:
getResolution().getColumnSource().getFinalTable()
SELECT title FROM (SELECT * FROM books) sub
For the 'title' column in outer SELECT:
- getSourceTable() → TTable for subquery 'sub' (tableType=subquery)
- resolution.getFinalTable() → TTable for 'books' (the physical table)
sourceTable,
ColumnSource.getFinalTable()public void setResolveStatus(int resolveStatus)
public int getResolveStatus()
public void TObjectName()
public boolean isSubscripts()
CREATE TABLE sal_emp (
name text,
pay_by_quarter integer[],
schedule text[][]
);
In the above SQL, this method returns true for pay_by_quarter column.public void setIndirection(TIndirection indirection)
public List<TExpression> getSubscriptExpressions()
arr[n], payload.items[idx].name: column
references that TSQLResolver2 and the lineage analyzer read like any other (Mantis 4817). Empty when the name
has no subscript.public TIndirection getIndirection()
public void setPropertyToken(TSourceToken propertyToken)
public TSourceToken getAtsign()
public TSourceToken getMethodToken()
public TSourceToken getPropertyToken()
public TSourceToken getServerToken()
public TSourceToken getExclamationmark()
public TObjectName getDblink()
remoreserver in this objectName: scott.emp@remoreserverpublic TSourceToken getDatabaseToken()
public void setTableDetermined(boolean tableDetermined)
public boolean isTableDetermined()
select name from emp, dept
In the above SQL, the name column can't be determined which table it belongs to.
Below is a more complicated SQL that shows the relationship between column and table.
select
s2.s2t1a1,
s3.s3t1a1
from
(
select *
from subselect2table1 s2t1
) s2,
(
select *
from subselect3table1, subselect3table2
) s3
column s2t1a1 was linked to subselect2table1, isTableDetermined() returns true for this column.
isTableDetermined() returns false for this column.
Provide database metadata will help GSP links the column to the table correctly.
TGSqlParser.setMetaDatabase(gudusoft.gsqlparser.IMetaDatabase)public void attributesToPropertyToken(TObjectNameList attributes)
teradata:
column.attribute()
column.attribute().attribute()
attributes - public void setColumnAttributes(TObjectNameList columnAttributes)
public TObjectNameList getColumnAttributes()
CREATE TYPE school_record AS (
school_name VARCHAR(20),
GPA FLOAT);
CREATE TYPE college_record AS (
school school_record,
major VARCHAR(20),
minor VARCHAR(20));
CREATE TABLE student_record (
student_id INTEGER,
Last_name VARCHAR(20),
First_name VARCHAR(20),
high_school school_record,
college college_record);
SELECT student_id, last_name, first_name,
high_school.school_name(), high_school.GPA(),
college.school().school_name(), college.school().GPA(),
college.major(), college.minor()
FROM student_record;
SELECT *.ALL FROM student_record;
SELECT student_record.*.ALL;
Take this column college.school().school_name() for example, the partToken of this objectName
should be college, and the value returned by this method should be
school().school_name()
PLEASE NOTE THAT CURRENT VERSION CAN'T HANDLE THE ABOVE SQL CORRECTLY.
public void setObjectType(int objectType)
setDbObjectType(gudusoft.gsqlparser.EDbVendor, gudusoft.gsqlparser.EDbObjectType) insteadobjectType - object type of this objectNamepublic void setDbObjectType(EDbVendor dbVendor, EDbObjectType dbObjectType)
public void setDbObjectTypeDirectly(EDbObjectType dbObjectType)
public void setDbObjectType(EDbObjectType dbObjectType)
dbObjectType - database object typepublic EDbObjectType getDbObjectType()
EDbObjectType.column, getPartToken() represents
the column name, for all other object type, the name of this database object is stored in getObjectToken()public int getObjectType()
getDbObjectType() instead.public void setAtsign(TSourceToken atsign)
public void setDblink(TObjectName dblink)
public void setDblink(TObjectName dblink, boolean linkToDB)
public void setServerToken(TSourceToken serverToken)
public void setDatabaseToken(TSourceToken databaseToken, boolean implicit)
public void setDatabaseToken(TSourceToken databaseToken)
public void setObjectToken(TSourceToken objectToken)
public void setPartToken(TSourceToken partToken)
public void setMethodToken(TSourceToken methodToken)
public void setSchemaToken(TSourceToken schemaToken, boolean implicit)
public void setSchemaToken(TSourceToken schemaToken)
public void setPackageToken(TSourceToken packageToken)
public TSourceToken getPackageToken()
public TSourceToken getObjectToken()
public TSourceToken getPartToken()
getDbObjectType() is EDbObjectType.column.
getColumnToken() returns the same value.public TSourceToken getSchemaToken()
public String getPackageString()
public String getServerString()
public String getDatabaseString()
public String getSchemaString()
public String getImplictSchemaString()
getSchemaString()
This method is only valid when the dbObjectType is a schema object.public IdentifierInputForm getImplictSchemaForm()
getImplictSchemaString() came from, so a consumer can key it:
IdentifierInputForm.CATALOG_STORED when the name was found by
searching the catalog and the text is the schema the catalog holds it in (TSQLSchema.getName()),
IdentifierInputForm.SQL_LEXICAL when it is a spelling: the name's
own qualifier, or a session default a resolver stamped, which the catalog itself reads as SQL.
On PostgreSQL the two read Mixed as different schemas.getImplictSchemaString() has no valuepublic IdentifierInputForm getImplictDatabaseForm()
getImplictDatabaseString() came from; see getImplictSchemaForm().getImplictDatabaseString() has no valuepublic void setImplictDatabaseName(String implictDatabaseName)
public void setImplictSchemaName(String implictSchemaName)
public String getImplictDatabaseString()
protected TSQLSchema searchImplicitSchema()
public TSourceToken getTableToken()
getObjectToken() if getDbObjectType()
is EDbObjectType.tablepublic String getTableString()
Note on the returned value: for a qualified column
reference like c.sbCustId in FROM sbCustomer c,
this returns the user-written qualifier "c" (the
alias), not the resolved physical table "sbCustomer". The
method does not disambiguate alias from table name — it returns
whatever literal appears before the dot in the source SQL. For
the resolved physical table, use getSourceTable() and
read TTable.getName() on the result; that goes through
the two-phase semantic resolver which performs the alias → table
mapping. See MantisBT
#4464 — a dedicated convenience accessor
getResolvedTableName() is proposed in that ticket to make
the resolved-table use case more discoverable; it will be added
additively without changing this method's behavior or signature.
getSourceTable()public String getObjectString()
public String getPartString()
public String getNormalizedDatabaseString()
This method caches the normalized database name to avoid repeated normalize() calls. The cache is invalidated automatically when the IdentifierProfile changes (e.g., vendor switch).
public String getNormalizedSchemaString()
This method caches the normalized schema name to avoid repeated normalize() calls. The cache is invalidated automatically when the IdentifierProfile changes.
public String getNormalizedTableString()
This method caches the normalized table name to avoid repeated normalize() calls. The cache is invalidated automatically when the IdentifierProfile changes.
public String getNormalizedColumnString()
This method caches the normalized column name (from partToken) to avoid repeated normalize() calls. The cache is invalidated automatically when the IdentifierProfile changes.
public String getNormalizedServerString()
This method caches the normalized server name to avoid repeated normalize() calls. The cache is invalidated automatically when the IdentifierProfile changes.
public void setExclamationmark(TSourceToken exclamationmark)
public String getAnsiSchemaName()
public String getAnsiCatalogName()
public int getNumberOfPart()
public static TObjectName createObjectName(EDbVendor dbVendor, EDbObjectType dbObjectType)
public static TObjectName createObjectName(EDbVendor dbVendor, EDbObjectType dbObjectType, TSourceToken token1)
public static TObjectName createObjectName(EDbVendor dbVendor, EDbObjectType dbObjectType, String str)
public static TObjectName createObjectName(EDbVendor dbVendor, EDbObjectType dbObjectType, TSourceToken token1, TSourceToken token2)
public static TObjectName createObjectName(EDbVendor dbVendor, EDbObjectType dbObjectType, TSourceToken token1, TSourceToken token2, TSourceToken token3)
public static TObjectName createObjectName(EDbVendor dbVendor, EDbObjectType dbObjectType, TSourceToken token1, TSourceToken token2, TSourceToken token3, TSourceToken token4)
public void splitNameInQuotedIdentifier()
public void init(Object arg1)
TParseTreeNodeinit in class TParseTreeNodearg1 - first argumentpublic void init(Object arg1, Object arg2)
init in class TParseTreeNodepublic void init(EDbObjectType dbObjectType, Object arg1, Object arg2, Object arg3)
public void init(Object arg1, Object arg2, Object arg3)
init in class TParseTreeNodepublic void init(Object arg1, Object arg2, Object arg3, Object arg4)
init in class TParseTreeNodepublic void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
init in class TParseTreeNodepublic void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6)
init in class TParseTreeNodepublic void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7)
init in class TParseTreeNodepublic void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8)
init in class TParseTreeNodepublic void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9)
init in class TParseTreeNodepublic void init(Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10)
init in class TParseTreeNodepublic List<TSourceToken> getAdditionalParts()
public long getColumnNo()
getColumnNo in class TParseTreeNodepublic long getLineNo()
getLineNo in class TParseTreeNodepublic TObjectNameList getReferencedObjects()
public String getColumnNameOnly()
public void accept(TParseTreeVisitor v)
TParseTreeNodeaccept in interface Visitableaccept in class TParseTreeNodev - visitor is a descendant class of TParseTreeVisitorpublic void acceptChildren(TParseTreeVisitor v)
TParseTreeNodeacceptChildren in interface VisitableacceptChildren in class TParseTreeNodev - visitor is a descendant class of TParseTreeVisitorpublic TSourceToken getColumnToken()
public boolean isAttributeNameInObjectName(TSourceToken leftparen, TSourceToken rightparen)
public void mergeObjectName(TObjectName objectName)
public void mergeObjectName(TObjectName objectName, TObjectName objectName2)
public void columnToProperty()
public List<TSourceToken> getIdentifierChain()
payload.items[1].name gives payload, items, and e.payload.address.city gives all four
parts. A name of five or more parts gives all of them too, although the grammar keeps only its first part in
the name slots and the rest in getIndirection(). The parse decides what an identifier is: a subscript,
a : path, a bind variable or a method call ends the chain, and a name with a wildcard part has no chain.
public List<TSourceToken> getStarQualifierChain()
e.payload.* gives
e, payload, BigQuery customer.address.* gives customer, address. The wildcard comes from
the parse, the asterisk token, never from the text. Empty for any other name.public void columnToFieldPath(int fieldCount)
fieldCount fields of its value, counted from the end of
getIdentifierChain(): the part before the fields becomes the column token, the first field the
property token, and the parts before the column its qualifier.
This is columnToProperty() for a field path of any length. In Athena payload.address.city the
grammar fills the slots as schema payload, table address, column city; with two fields it
becomes column payload with property address, and e.payload.address.city becomes table
e, column payload, property address (Mantis 4822). The fields stay readable from the
resolver's field path and from getIndirection(). Calling it again with the same count changes nothing.
fieldCount - how many trailing parts of the chain are fields, at least 1public StructuredColumnPath getFieldPathRead()
customer.address.city reads
customer.address.city; Athena payload.items[1].name reads payload.items[*].name, a
subscript being the array element segment of StructuredColumnPath.
This is the one place that answers which column a reference reads and which field below it. The evidence is
what TSQLResolver2 proved: a struct-field reading of the name (getColumnSource() with a field path), or
BigQuery's reading of a name of three or more parts without an alias (getStructFieldHint()). In the
Trino family the parse adds the parts after those fields and after a subscript, which the resolver does not
read: an array element and its fields (items[1].name reads items[*].name).
public TSourceToken getFieldPathBaseToken()
getFieldPathRead() reads, such as customer in
o.customer.address.city; null when the reference reads a whole column.public StructuredColumnPath getStructStarPath()
customer.* reads
every field of customer, customer.address.* every field of customer.address, and
Athena e.payload.* every field of payload. The evidence is what TSQLResolver2 proved, as for
getFieldPathRead(): a struct-field reading whose field path ends at the wildcard, BigQuery's reading of
a name of three or more parts without an alias, or, in the Trino family, the column the name was bound to with
the wildcard right after it.public TSourceToken getStructStarBaseToken()
getStructStarPath() starts at; null when that is null.public void appendObjectName(TObjectName objectName)
public void setCommentString(TSourceToken commentString)
public TSourceToken getCommentString()
public String coordinate()