use of org.teiid.query.sql.symbol.GroupSymbol 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.GroupSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionMakeDepInline2.
/*+* Select a From db.g1 MAKEDEP JOIN db.g2 ON a = b */
@Test
public void testOptionMakeDepInline2() {
// $NON-NLS-1$
GroupSymbol g1 = new GroupSymbol("db.g1");
// $NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2");
// $NON-NLS-1$
ElementSymbol a = new ElementSymbol("a");
// $NON-NLS-1$
ElementSymbol b = new ElementSymbol("b");
List<Object> crits = new ArrayList<Object>();
crits.add(new CompareCriteria(a, CompareCriteria.EQ, b));
JoinPredicate jp = new JoinPredicate(new UnaryFromClause(g1), new UnaryFromClause(g2), JoinType.JOIN_INNER, crits);
jp.getLeftClause().setMakeDep(true);
From from = new From();
from.addClause(jp);
Select select = new Select();
select.addSymbol(a);
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"Select a From db.g1 MAKEDEP JOIN db.g2 ON a = b", // $NON-NLS-1$
"SELECT a FROM /*+ MAKEDEP */ db.g1 INNER JOIN db.g2 ON a = b", query);
}
use of org.teiid.query.sql.symbol.GroupSymbol 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.GroupSymbol in project teiid by teiid.
the class TestOptionsAndHints method testDeleteWithOption.
@Test
public void testDeleteWithOption() {
Delete delete = new Delete();
// $NON-NLS-1$
delete.setGroup(new GroupSymbol("m.g"));
Option option = new Option();
option.setNoCache(true);
delete.setOption(option);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"DELETE FROM m.g OPTION NOCACHE", // $NON-NLS-1$
"DELETE FROM m.g OPTION NOCACHE", delete);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionMakeDependent3.
/*+* Select a From db.g Option makedep a.b.c, d.e.f, x.y.z */
@Test
public void testOptionMakeDependent3() {
// $NON-NLS-1$
GroupSymbol g = new GroupSymbol("db.g");
From from = new From();
from.addGroup(g);
Select select = new Select();
// $NON-NLS-1$
ElementSymbol a = new ElementSymbol("a");
select.addSymbol(a);
Option option = new Option();
// $NON-NLS-1$
option.addDependentGroup("a.b.c");
// $NON-NLS-1$
option.addDependentGroup("d.e.f");
// $NON-NLS-1$
option.addDependentGroup("x.y.z");
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setOption(option);
// $NON-NLS-1$
TestParser.helpTest(// $NON-NLS-1$
"Select a From db.g Option makedep a.b.c, d.e.f, x.y.z", // $NON-NLS-1$
"SELECT a FROM db.g OPTION MAKEDEP a.b.c, d.e.f, x.y.z", query);
}
Aggregations