use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionMakeDepInline3.
/*+* Select a From (db.g1 MAKEDEP JOIN db.g2 ON a = b) LEFT OUTER JOIN db.g3 MAKEDEP ON a = c */
@Test
public void testOptionMakeDepInline3() {
// $NON-NLS-1$
GroupSymbol g1 = new GroupSymbol("db.g1");
// $NON-NLS-1$
GroupSymbol g2 = new GroupSymbol("db.g2");
// $NON-NLS-1$
GroupSymbol g3 = new GroupSymbol("db.g3");
// $NON-NLS-1$
ElementSymbol a = new ElementSymbol("a");
// $NON-NLS-1$
ElementSymbol b = new ElementSymbol("b");
// $NON-NLS-1$
ElementSymbol c = new ElementSymbol("c");
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);
List<Object> crits2 = new ArrayList<Object>();
crits2.add(new CompareCriteria(a, CompareCriteria.EQ, c));
JoinPredicate jp2 = new JoinPredicate(jp, new UnaryFromClause(g3), JoinType.JOIN_LEFT_OUTER, crits2);
jp2.getRightClause().setMakeDep(true);
From from = new From();
from.addClause(jp2);
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) LEFT OUTER JOIN db.g3 MAKEDEP ON a = c", // $NON-NLS-1$
"SELECT a FROM (/*+ MAKEDEP */ db.g1 INNER JOIN db.g2 ON a = b) LEFT OUTER JOIN /*+ MAKEDEP */ db.g3 ON a = c", query);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionMakeDepInline1.
/*+* Select a From db.g1 JOIN db.g2 MAKEDEP ON a = b */
@Test
public void testOptionMakeDepInline1() {
// $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.getRightClause().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 JOIN db.g2 MAKEDEP ON a = b", // $NON-NLS-1$
"SELECT a FROM db.g1 INNER JOIN /*+ MAKEDEP */ db.g2 ON a = b", query);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestOptionsAndHints method testCacheMultipleComments.
@Test
public void testCacheMultipleComments() {
// $NON-NLS-1$
String sql = "/* hello */ /*+ cache */ /* world */ 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);
query.setCacheHint(new CacheHint());
// $NON-NLS-1$
TestParser.helpTest(sql, "/*+ cache */ SELECT * FROM t1", query);
}
use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionalFromClause1_3.
@Test
public void testOptionalFromClause1_3() {
// $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.GroupSymbol in project teiid by teiid.
the class TestOptionsAndHints method testOptionMakeDependent1.
/*+* Select a From db.g Option SHOWPLAN */
/*+* Select a From db.g Option makedep a.b.c */
@Test
public void testOptionMakeDependent1() {
// $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");
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", // $NON-NLS-1$
"SELECT a FROM db.g OPTION MAKEDEP a.b.c", query);
}
Aggregations