use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestLimitParsing method testLimitWithReferences1.
@Test
public void testLimitWithReferences1() {
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 Reference(0), new Constant(new Integer(100))));
// $NON-NLS-1$ //$NON-NLS-2$
helpTest("Select * from a limit ?,100", "SELECT * FROM a LIMIT ?, 100", query);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestLimitParsing method testFetchFirst.
@Test
public void testFetchFirst() {
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(2)));
// $NON-NLS-1$ //$NON-NLS-2$
helpTest("Select * from a fetch first 2 rows only", "SELECT * FROM a LIMIT 2", query);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionalFromClause6.
@Test
public void testOptionalFromClause6() {
// $NON-NLS-1$
String sql = "SELECT * FROM t1 INNER JOIN /*+ optional */ (select a from t1, t2) AS x ON t1.a=x.a";
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();
// $NON-NLS-1$
select.addSymbol(new ElementSymbol("a"));
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);
UnaryFromClause ufc = new UnaryFromClause();
// $NON-NLS-1$
ufc.setGroup(new GroupSymbol("t1"));
// $NON-NLS-1$
SubqueryFromClause sfc = new SubqueryFromClause("x", query2);
sfc.setOptional(true);
List<Object> criteria = new ArrayList<Object>();
// $NON-NLS-1$//$NON-NLS-2$
criteria.add(new CompareCriteria(new ElementSymbol("t1.a"), AbstractCompareCriteria.EQ, new ElementSymbol("x.a")));
JoinPredicate joinPredicate = new JoinPredicate(ufc, sfc, JoinType.JOIN_INNER, criteria);
from.addClause(joinPredicate);
query.setFrom(from);
// $NON-NLS-1$
TestParser.helpTest(sql, "SELECT * FROM t1 INNER JOIN /*+ optional */ (SELECT a FROM t1, t2) AS x ON t1.a = x.a", query);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionalFromClause1_5.
@Test
public void testOptionalFromClause1_5() {
// $NON-NLS-1$
String sql = "SELECT * 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);
}
use of org.teiid.query.sql.symbol.MultipleElementSymbol in project teiid by teiid.
the class TestOptionsAndHints method testExpandedCacheHint.
@Test
public void testExpandedCacheHint() {
// $NON-NLS-1$
String sql = "/*+ cache( pref_mem ttl:2000) */ SELECT * FROM t1";
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);
CacheHint hint = new CacheHint();
hint.setPrefersMemory(true);
hint.setTtl(Long.valueOf(2000));
query.setCacheHint(hint);
// $NON-NLS-1$
TestParser.helpTest(sql, "/*+ cache(pref_mem ttl:2000) */ SELECT * FROM t1", query);
}
Aggregations