|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgudusoft.gsqlparser.nodes.TParseTreeNode
gudusoft.gsqlparser.nodes.TNodeWithAliasClause
gudusoft.gsqlparser.nodes.TJoin
public class TJoin
A list of join 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.
SQL 1:
select f from t1
size of joins will be 1, t1 information can be fetch via joins.getJoin(0).getTable()
SQL 2:
select f from t1,t2
size of joins will be 2,
t1 information can be fetch via joins.getJoin(0).getTable()
t2 information can be fetch via joins.getJoin(1).getTable()
SQL 3:
select f from t1 join t2 on t1.f1 = t2.f1
size of joins will be 1,
t1 information can be fetch via joins.getJoin(0).getTable()
In order to access t2, we need to introduce a new class TJoinItem
which includes all information about t2 and join condition after on keyword.
There is a property named joinItems of TJoin
which is type of TJoinItemList
that includes a list of TJoinItem
.
this property can be access via getJoinItems()
.
Now, t2 can be fetch via joins.getJoin(0).getJoinItems().getJoinItem(0).getTable()
SQL 4:
select f from t1 join t2 on t1.f1 = t2.f1 join t3 on t1.f1 = t3.f1
size of joins will be 1,
t1 can be fetch via joins.getJoin(0).getTable()
t2 can be fetch via joins.getJoin(0).getJoinItems().getJoinItem(0).getTable()
t3 can be fetch via joins.getJoin(0).getJoinItems().getJoinItem(1).getTable()
Constructor Summary | |
---|---|
TJoin()
|
Method Summary | |
---|---|
void |
accept(TParseTreeVisitor v)
|
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. |
TTable |
getTable()
|
void |
setJoin(TJoin join)
|
void |
setJoinItems(TJoinItemList joinItems)
|
void |
setKind(int kind)
|
void |
setTable(TTable table)
|
Methods inherited from class gudusoft.gsqlparser.nodes.TNodeWithAliasClause |
---|
setAliasClause, toString |
Methods inherited from class gudusoft.gsqlparser.nodes.TParseTreeNode |
---|
addAllMyTokensToTokenList, doParse, getColumnNo, getDummyTag, getEndToken, getGsqlparser, getLineNo, getNodeType, getStartToken, init, init, init, init, init, init, setDummyTag, setEndToken, setEndToken, setGsqlparser, setNodeType, setStartToken, setStartToken, setString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TJoin()
Method Detail |
---|
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 represention 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 represention 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 represention 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)
accept
in interface Visitable
accept
in class TParseTreeNode
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |