public class TJoin extends TNodeWithAliasClause
TCustomSqlStatement.joins
represents table sources in following clauses of SQL statement:
Each table source in from clause was treated as a join which is type of TJoin
.
The reason for this design is that we can treat all table sources in from clause in a uniform way.
Constructor and Description |
---|
TJoin() |
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
|
TAliasClause |
getAliasClause() |
TJoin |
getJoin() |
TJoinItemList |
getJoinItems()
List of joinItems.
|
int |
getKind()
According to the table source in from clause, there are 3 kinds of join.
|
int |
getNestedParen() |
TTable |
getTable() |
boolean |
isWithParen() |
void |
setJoin(TJoin join) |
void |
setJoinItems(TJoinItemList joinItems) |
void |
setKind(int kind) |
void |
setNestedParen(int nestedParen) |
void |
setTable(TTable table) |
void |
setWithParen(boolean withParen) |
setAliasClause, toString
addAllMyTokensToTokenList, appendString, doParse, fastSetString, getColumnNo, getDummyTag, getEndToken, getGsqlparser, getLineNo, getNodeType, getStartToken, init, init, init, init, init, init, removeAllMyTokensFromTokenList, setDummyTag, setEndToken, setEndToken, setEndToken, setEndToken, setGsqlparser, setIncludingComment, setNodeType, setStartToken, setStartToken, setStartToken, setStartToken, setString, toScript
public void setNestedParen(int nestedParen)
public int getNestedParen()
public void setWithParen(boolean withParen)
public boolean isWithParen()
public void setJoinItems(TJoinItemList joinItems)
public void setJoin(TJoin join)
public void setTable(TTable table)
public void setKind(int kind)
public TJoinItemList getJoinItems()
SQL 1:
Text in Item 0 will be: left join t2 on t1.f1 = t2.f1select f from t1 left join t2 on t1.f1 = t2.f1 right join t3 on t1.f1 = t3.f1
Text in Item 1 will be: right join t3 on t1.f1 = t3.f1
Check TJoinItem
to see how information was organized.
public TJoin getJoin()
select a_join.f1 from (a as a_alias left join a1 on a1.f1 = a_alias.f1) as a_join join b on a_join.f1 = b.f1;
public TTable getTable()
select f from t1 join t2 on t1.f1 = t2.f1
public int getKind()
TBaseType.join_source_fake
, it's a fake join like the whole from clause was represented by this class, you can get text representation of this from clause by using toString() method, it returns "t1" .select f from t1
and table t1 can be fetch from getTable()
.
TBaseType.join_source_table
,the whole from clause was represented by this class, you can get text representation of this from clause by using toString() method, it returns "t1 join t2 on t1.f1 = t2.f1".select f from t1 join t2 on t1.f1 = t2.f1
t1 can be fetch from getTable()
.
TBaseType.join_source_join
,
the whole from clause was represented by this class, you can get text representation of this from clause by using toString() method, it returns "(a as a_alias left join a1 on a1.f1 = a_alias.f1) as a_join join b on a_join.f1 = b.f1".select a_join.f1 from (a as a_alias left join a1 on a1.f1 = a_alias.f1) as a_join join b on a_join.f1 = b.f1;
(a as a_alias left join a1 on a1.f1 = a_alias.f1) can be fetched from getJoin()
.
public TAliasClause getAliasClause()
getAliasClause
in class TNodeWithAliasClause
getJoin()
, valid only when = TBaseType#join_source_join
.
In this SQL, alias is "as a_join"
select a_join.f1 from (a as a_alias left join a1 on a1.f1 = a_alias.f1) as a_join join b on a_join.f1 = b.f1;
But in this SQL, alias is null, "as t1" is the alias of t1.
select f from t as t1 join t2 on t1.f1 = t2.f1
public void accept(TParseTreeVisitor v)
TParseTreeNode
accept
in interface Visitable
accept
in class TParseTreeNode
v
- visitor is a descendant class of TParseTreeVisitor
public void acceptChildren(TParseTreeVisitor v)
TParseTreeNode
acceptChildren
in interface Visitable
acceptChildren
in class TParseTreeNode
v
- visitor is a descendant class of TParseTreeVisitor
Copyright © 2019. All rights reserved.