use of org.teiid.query.sql.lang.Select in project teiid by teiid.
the class TestLimitParsing method testLimitWithReferences2.
@Test
public void testLimitWithReferences2() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
// $NON-NLS-1$
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Constant(new Integer(50)), new Reference(0)));
// $NON-NLS-1$ //$NON-NLS-2$
helpTest("Select * from a limit 50,?", "SELECT * FROM a LIMIT 50, ?", query);
}
use of org.teiid.query.sql.lang.Select in project teiid by teiid.
the class TestLimitParsing method testFetchFirstRow.
@Test
public void testFetchFirstRow() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
// $NON-NLS-1$
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(null, new Constant(1)));
// $NON-NLS-1$ //$NON-NLS-2$
helpTest("Select * from a fetch first row only", "SELECT * FROM a LIMIT 1", query);
}
use of org.teiid.query.sql.lang.Select in project teiid by teiid.
the class TestLimitParsing method testOffsetFetch.
@Test
public void testOffsetFetch() {
Query query = new Query();
Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
// $NON-NLS-1$
From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
query.setSelect(select);
query.setFrom(from);
query.setLimit(new Limit(new Constant(2), new Constant(5)));
// $NON-NLS-1$ //$NON-NLS-2$
helpTest("Select * from a offset 2 rows fetch first 5 rows only", "SELECT * FROM a LIMIT 2, 5", query);
}
use of org.teiid.query.sql.lang.Select 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.Select in project teiid by teiid.
the class TestSetQueryParsing method createTestQuery.
private Query createTestQuery(String group) {
GroupSymbol g = new GroupSymbol(group);
From from = new From();
from.addGroup(g);
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
Query query1 = new Query();
query1.setSelect(select);
query1.setFrom(from);
return query1;
}
Aggregations