use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method testUnionAll.
/**
* SELECT a FROM g UNION ALL select b from h
*/
@Test
public void testUnionAll() {
// $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(Operation.UNION);
setQuery.setAll(true);
setQuery.setLeftQuery(query1);
setQuery.setRightQuery(query2);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"SELECT a FROM g UNION ALL select b from h", // $NON-NLS-1$
"SELECT a FROM g UNION ALL SELECT b FROM h", setQuery);
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method testUnion.
// ======================= UNION ================================================
/**
* SELECT a FROM g UNION select b from h
*/
@Test
public void testUnion() {
SetQuery setQuery = exampleSetQuery(Operation.UNION);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"SELECT a FROM g UNION select b from h", // $NON-NLS-1$
"SELECT a FROM g UNION SELECT b FROM h", setQuery);
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method testMultipleValues.
@Test
public void testMultipleValues() {
SetQuery setQuery = new SetQuery(Operation.UNION);
setQuery.setAll(true);
Select select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("c1"));
Query query = new Query();
query.setSelect(select);
setQuery.setLeftQuery(query);
select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("c2"));
query = new Query();
query.setSelect(select);
setQuery.setRightQuery(query);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"values (c1), (c2)", // $NON-NLS-1$
"SELECT c1 UNION ALL SELECT c2", setQuery);
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method testExcept.
@Test
public void testExcept() {
SetQuery setQuery = exampleSetQuery(Operation.EXCEPT);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"SELECT a FROM g except select b from h", // $NON-NLS-1$
"SELECT a FROM g EXCEPT SELECT b FROM h", setQuery);
}
use of org.teiid.query.sql.lang.SetQuery in project teiid by teiid.
the class TestSetQueryParsing method testThreeUnions.
/**
* select c1 from g1 union select c2 from g2 union all select c3 from g3 union select c4 from g4
*/
@Test
public void testThreeUnions() {
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(SetQuery.Operation.UNION, true, setQuery, query);
// $NON-NLS-1$
g = new GroupSymbol("g4");
from = new From();
from.addGroup(g);
select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("c4"));
query = new Query();
query.setSelect(select);
query.setFrom(from);
setQuery = new SetQuery(SetQuery.Operation.UNION, false, setQuery, query);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"select c1 from g1 union select c2 from g2 union all select c3 from g3 union select c4 from g4", // $NON-NLS-1$
"SELECT c1 FROM g1 UNION SELECT c2 FROM g2 UNION ALL SELECT c3 FROM g3 UNION SELECT c4 FROM g4", setQuery);
}
Aggregations