-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
180 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 34 additions & 32 deletions
66
src/main/java/net/sf/jsqlparser/statement/select/FromItemVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
/* ================================================================ | ||
* JSQLParser : java based sql parser | ||
* ================================================================ | ||
* | ||
* Project Info: http://jsqlparser.sourceforge.net | ||
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it); | ||
* | ||
* (C) Copyright 2004, by Leonardo Francalanci | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under the terms | ||
* of the GNU Lesser General Public License as published by the Free Software Foundation; | ||
* either version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with this | ||
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
*/ | ||
package net.sf.jsqlparser.statement.select; | ||
|
||
import net.sf.jsqlparser.schema.Table; | ||
|
||
public interface FromItemVisitor { | ||
public void visit(Table tableName); | ||
|
||
public void visit(SubSelect subSelect); | ||
|
||
public void visit(SubJoin subjoin); | ||
} | ||
/* ================================================================ | ||
* JSQLParser : java based sql parser | ||
* ================================================================ | ||
* | ||
* Project Info: http://jsqlparser.sourceforge.net | ||
* Project Lead: Leonardo Francalanci (leoonardoo@yahoo.it); | ||
* | ||
* (C) Copyright 2004, by Leonardo Francalanci | ||
* | ||
* This library is free software; you can redistribute it and/or modify it under the terms | ||
* of the GNU Lesser General Public License as published by the Free Software Foundation; | ||
* either version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | ||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along with this | ||
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | ||
* Boston, MA 02111-1307, USA. | ||
*/ | ||
package net.sf.jsqlparser.statement.select; | ||
|
||
import net.sf.jsqlparser.schema.Table; | ||
|
||
public interface FromItemVisitor { | ||
public void visit(Table tableName); | ||
|
||
public void visit(SubSelect subSelect); | ||
|
||
public void visit(SubJoin subjoin); | ||
|
||
public void visit(LateralSubSelect lateralSubSelect); | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/net/sf/jsqlparser/statement/select/LateralSubSelect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.sf.jsqlparser.statement.select; | ||
|
||
|
||
/** | ||
* A lateral subselect followed by an alias. | ||
* @author Tobias Warneke | ||
*/ | ||
public class LateralSubSelect implements FromItem { | ||
private SubSelect subSelect; | ||
private String alias; | ||
|
||
public void setSubSelect(SubSelect subSelect) { | ||
this.subSelect = subSelect; | ||
} | ||
|
||
public SubSelect getSubSelect() { | ||
return subSelect; | ||
} | ||
|
||
@Override | ||
public void accept(FromItemVisitor fromItemVisitor) { | ||
fromItemVisitor.visit(this); | ||
} | ||
|
||
@Override | ||
public String getAlias() { | ||
return alias; | ||
} | ||
|
||
@Override | ||
public void setAlias(String alias) { | ||
this.alias = alias; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "LATERAL" + subSelect.toString() + ((alias != null) ? " AS " + alias : ""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/test/resources/net/sf/jsqlparser/test/select/complex-lateral-select-request.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
SELECT | ||
O.ORDERID, | ||
O.CUSTNAME, | ||
OL.LINETOTAL, | ||
OC.ORDCHGTOTAL, | ||
OT.TAXTOTAL | ||
FROM | ||
ORDERS O, | ||
LATERAL ( | ||
SELECT | ||
SUM(NETAMT) AS LINETOTAL | ||
|
||
FROM | ||
ORDERLINES LINES | ||
|
||
WHERE | ||
LINES.ORDERID=O.ORDERID | ||
) AS OL, | ||
LATERAL ( | ||
SELECT | ||
SUM(CHGAMT) AS ORDCHGTOTAL | ||
|
||
FROM | ||
ORDERCHARGES CHARGES | ||
|
||
WHERE | ||
LINES.ORDERID=O.ORDERID | ||
) AS OC, | ||
LATERAL ( | ||
SELECT | ||
SUM(TAXAMT) AS TAXTOTAL | ||
|
||
FROM | ||
ORDERTAXES TAXES | ||
|
||
WHERE | ||
TAXES.ORDERID=O.ORDERID | ||
) AS OT |