use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method exampleSetQuery.
private SetQuery exampleSetQuery(Operation op) {
// $NON-NLS-1$
GroupSymbol g = new GroupSymbol("g");
From from = new From();
from.addGroup(g);
Select select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("a"));
Query query1 = new Query();
query1.setSelect(select);
query1.setFrom(from);
// $NON-NLS-1$
g = new GroupSymbol("h");
from = new From();
from.addGroup(g);
select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("b"));
Query query2 = new Query();
query2.setSelect(select);
query2.setFrom(from);
SetQuery setQuery = new SetQuery(op);
setQuery.setAll(false);
setQuery.setLeftQuery(query1);
setQuery.setRightQuery(query2);
return setQuery;
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method testIntersectPresedence.
@Test
public void testIntersectPresedence() {
// $NON-NLS-1$ //$NON-NLS-2$
SetQuery setQuery = new SetQuery(Operation.INTERSECT, false, createTestQuery("t2"), createTestQuery("t3"));
// $NON-NLS-1$
setQuery = new SetQuery(Operation.EXCEPT, false, createTestQuery("t1"), setQuery);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"select * from t1 EXCEPT select * from t2 INTERSECT select * from t3", // $NON-NLS-1$
"SELECT * FROM t1 EXCEPT (SELECT * FROM t2 INTERSECT SELECT * FROM t3)", setQuery);
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method testTwoUnions.
/**
* select c1 from g1 union select c2 from g2 union select c3 from g3
*/
@Test
public void testTwoUnions() {
SetQuery setQuery = new SetQuery(Operation.UNION);
setQuery.setAll(false);
// $NON-NLS-1$
GroupSymbol g = new GroupSymbol("g1");
From from = new From();
from.addGroup(g);
Select select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("c1"));
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
setQuery.setLeftQuery(query);
// $NON-NLS-1$
g = new GroupSymbol("g2");
from = new From();
from.addGroup(g);
select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("c2"));
query = new Query();
query.setSelect(select);
query.setFrom(from);
setQuery.setRightQuery(query);
// $NON-NLS-1$
g = new GroupSymbol("g3");
from = new From();
from.addGroup(g);
select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("c3"));
query = new Query();
query.setSelect(select);
query.setFrom(from);
setQuery = new SetQuery(Operation.UNION, false, setQuery, query);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"select c1 from g1 union select c2 from g2 union select c3 from g3", // $NON-NLS-1$
"SELECT c1 FROM g1 UNION SELECT c2 FROM g2 UNION SELECT c3 FROM g3", setQuery);
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method testIntersect.
@Test
public void testIntersect() {
SetQuery setQuery = exampleSetQuery(Operation.INTERSECT);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"SELECT a FROM g intersect select b from h", // $NON-NLS-1$
"SELECT a FROM g INTERSECT SELECT b FROM h", setQuery);
}
Aggregations