public class TResultColumnList extends TParseTreeNodeList<TResultColumn>
modCountdbvendor, doubleLinkedTokenListToString, nodeActionAppend, nodeActionInsert, nodeActionRemove, nodeActionUnknown, nodeActionUpdate, nodeActionUpdateText, nodeChangeEndToken, nodeChangeStartToken| Constructor and Description |
|---|
TResultColumnList() |
| 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 |
addResultColumn(String ptext)
Used to add a result column manually when re-construct a select list
There must exist at least one column in column list in order to this function.
|
void |
addResultColumn(TResultColumn resultColumn)
Add a ResultColumn to the list
|
void |
doParse(TCustomSqlStatement psql,
ESqlClause plocation)
analyze this node
|
TResultColumn |
findLateralAliasDefinition(EDbVendor vendor,
TObjectName reference)
Find the SELECT-list column alias that an unqualified reference elsewhere in the
same SELECT block binds to — a "lateral column alias" reference such as
Snowflake's
SELECT val*2 AS derived_col FROM t WHERE derived_col > 1. |
TSourceToken |
getEndToken()
The last token of the node
|
TResultColumn |
getResultColumn(int position)
Get a ResultColumn from a column position (0-based) in the list
|
ArrayList<TResultColumn> |
getSortedColumns() |
TSourceToken |
getStartToken()
In teradata, the whole result column can be null, so this result column
should be ingored when get start token in result column list.
|
TParseTreeNode |
removeItem(int index) |
void |
removeResultColumn(int index) |
addAll, addElement, addNode, clear, elementAt, getElement, indexOf, init, init, init, init, insertElementAt, isListSeparatedByComma, iterator, removeElement, removeElementAt, removeElementWithoutSyncTokens, setListSeparatedByComma, size, TParseTreeNodeListaddAllMyTokensToTokenList, addToTokenChain, appendNewNode, calculateTokenCount, doAppendNewNode, fastSetString, getAnchorNode, getColumnNo, getCommentAfterNode, getCommentBeforeNode, getCompactString, getDummyTag, getEvaluateDatatype, getEvalValue, getGsqlparser, getLineNo, getLocation, getMd5, getNodeStatus, getNodeType, getParentObjectName, getPlainText, getTokenCount, hasNext, init, init, init, init, init, init, 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, toString, toString2clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorforEachRemainingpublic TResultColumnList()
public ArrayList<TResultColumn> getSortedColumns()
public void removeResultColumn(int index)
public TParseTreeNode removeItem(int index)
removeItem in class TParseTreeNodeList<TResultColumn>public void addResultColumn(String ptext)
ptext - public void addResultColumn(TResultColumn resultColumn)
resultColumn - The ResultColumn to add to the listpublic TResultColumn getResultColumn(int position)
position - The ResultColumn to get from the list (1-based)public TSourceToken getStartToken()
getStartToken in class TParseTreeNodeList<TResultColumn>public TSourceToken getEndToken()
TParseTreeNodegetEndToken in class TParseTreeNodeList<TResultColumn>public void doParse(TCustomSqlStatement psql, ESqlClause plocation)
TParseTreeNodeListdoParse in class TParseTreeNodeList<TResultColumn>psql - SQL statement this node belongs toplocation - SQL clause this node belongs topublic TResultColumn findLateralAliasDefinition(EDbVendor vendor, TObjectName reference)
SELECT val*2 AS derived_col FROM t WHERE derived_col > 1.
This is the SINGLE definition of that binding rule. Both consumers delegate here so the two paths can never drift apart:
TCustomSqlStatement.linkColumnToTable(),
which sets sourceColumn and deliberately leaves
sourceTable null;TSQLResolver2.handleSelectListAliasResolution().Fixing one and not the other yields a reference whose sourceColumn
is the alias while its sourceTable is a FROM-clause table that has no
such column — a wrong answer with nothing to flag it (MantisBT 4659).
The rule is vendor-gated twice: the dialect must support lateral column
aliases at all (TBaseType.isSupportLateralColumn(gudusoft.gsqlparser.EDbVendor)), and it must not
forbid referencing a SELECT-list alias outside ORDER BY
(TSQLEnv.isAliasReferenceForbidden). Oracle, MySQL, PostgreSQL,
BigQuery and friends forbid it, so for them such a name is NOT an alias
reference and this returns null.
The reference must also appear textually AFTER the alias it binds to. That
ordering rule is what keeps a column inside the alias's own defining
expression (CAST(id AS DECIMAL) AS id) bound to the real table column
rather than to the alias being defined.
vendor - the dialect of the enclosing statementreference - an unqualified column reference from the same SELECT blockTResultColumn, or null when this is not a
lateral column alias referencepublic void accept(TParseTreeVisitor v)
TParseTreeNodeaccept in interface Visitableaccept in class TParseTreeNodeList<TResultColumn>v - visitor is a descendant class of TParseTreeVisitorpublic void acceptChildren(TParseTreeVisitor v)
TParseTreeNodeacceptChildren in interface VisitableacceptChildren in class TParseTreeNodeList<TResultColumn>v - visitor is a descendant class of TParseTreeVisitor