use of org.teiid.query.sql.symbol.MultipleElementSymbol 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.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionalFromClause5.
@Test
public void testOptionalFromClause5() {
// $NON-NLS-1$
String sql = "SELECT * FROM t1, /*+ optional */ (select * from t1, t2) as x";
Query query = new Query();
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
query.setSelect(select);
From from = new From();
Query query2 = new Query();
select = new Select();
select.addSymbol(new MultipleElementSymbol());
query2.setSelect(select);
From from2 = new From();
// $NON-NLS-1$
from2.addGroup(new GroupSymbol("t1"));
// $NON-NLS-1$
from2.addGroup(new GroupSymbol("t2"));
query2.setFrom(from2);
// $NON-NLS-1$
SubqueryFromClause sfc = new SubqueryFromClause("x", query2);
sfc.setOptional(true);
// $NON-NLS-1$
from.addGroup(new GroupSymbol("t1"));
from.addClause(sfc);
query.setFrom(from);
// $NON-NLS-1$
TestParser.helpTest(sql, "SELECT * FROM t1, /*+ optional */ (SELECT * FROM t1, t2) AS x", query);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionalFromClause8.
@Test
public void testOptionalFromClause8() {
// $NON-NLS-1$
String sql = "SELECT b FROM t1, /*+ optional */ (/*+ optional */ (SELECT * FROM t1, t2) AS x INNER JOIN t3 ON x.a = t3.a)";
Query query = new Query();
Select select = new Select();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("b"));
query.setSelect(select);
From from = new From();
Query query2 = new Query();
select = new Select();
select.addSymbol(new MultipleElementSymbol());
From from2 = new From();
// $NON-NLS-1$
from2.addGroup(new GroupSymbol("t1"));
// $NON-NLS-1$
from2.addGroup(new GroupSymbol("t2"));
query2.setSelect(select);
query2.setFrom(from2);
// $NON-NLS-1$
SubqueryFromClause sfc = new SubqueryFromClause("x", query2);
sfc.setOptional(true);
UnaryFromClause ufc2 = new UnaryFromClause();
// $NON-NLS-1$
ufc2.setGroup(new GroupSymbol("t3"));
List<Object> criteria = new ArrayList<Object>();
// $NON-NLS-1$//$NON-NLS-2$
criteria.add(new CompareCriteria(new ElementSymbol("x.a"), AbstractCompareCriteria.EQ, new ElementSymbol("t3.a")));
JoinPredicate joinPredicate = new JoinPredicate(sfc, ufc2, JoinType.JOIN_INNER, criteria);
joinPredicate.setOptional(true);
UnaryFromClause ufc3 = new UnaryFromClause();
// $NON-NLS-1$
ufc3.setGroup(new GroupSymbol("t1"));
from.addClause(ufc3);
from.addClause(joinPredicate);
query.setFrom(from);
// $NON-NLS-1$
TestParser.helpTest(sql, "SELECT b FROM t1, /*+ optional */ (/*+ optional */ (SELECT * FROM t1, t2) AS x INNER JOIN t3 ON x.a = t3.a)", query);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testCacheHintUnion.
@Test
public void testCacheHintUnion() {
// $NON-NLS-1$
String sql = "/*+ cache( pref_mem) */ SELECT * FROM t1 union select * from t2";
Query query = new Query();
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
query.setSelect(select);
From from = new From();
UnaryFromClause ufc = new UnaryFromClause();
from.addClause(ufc);
// $NON-NLS-1$
ufc.setGroup(new GroupSymbol("t1"));
query.setFrom(from);
Query query1 = new Query();
select = new Select();
select.addSymbol(new MultipleElementSymbol());
query1.setSelect(select);
from = new From();
ufc = new UnaryFromClause();
from.addClause(ufc);
// $NON-NLS-1$
ufc.setGroup(new GroupSymbol("t2"));
query1.setFrom(from);
SetQuery sq = new SetQuery(Operation.UNION, false, query, query1);
CacheHint hint = new CacheHint();
hint.setPrefersMemory(true);
sq.setCacheHint(hint);
// $NON-NLS-1$
TestParser.helpTest(sql, "/*+ cache(pref_mem) */ SELECT * FROM t1 UNION SELECT * FROM t2", sq);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionalFromClause1_4.
@Test
public void testOptionalFromClause1_4() {
// $NON-NLS-1$
String sql = "SELECT * /*+ optional */ FROM /*+ OptiOnal */ t1, t2";
Query query = new Query();
Select select = new Select();
select.addSymbol(new MultipleElementSymbol());
query.setSelect(select);
From from = new From();
UnaryFromClause ufc = new UnaryFromClause();
// $NON-NLS-1$
ufc.setGroup(new GroupSymbol("t1"));
ufc.setOptional(true);
from.addClause(ufc);
// $NON-NLS-1$
from.addGroup(new GroupSymbol("t2"));
query.setFrom(from);
// $NON-NLS-1$
TestParser.helpTest(sql, "SELECT * FROM /*+ optional */ t1, t2", query);
}
Aggregations