Search in sources :

Example 91 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestOptionsAndHints method testOptionMakeNotDepInline4.

/*+* Select a From db.g1 MAKENOTDEP, db.g2 MAKENOTDEP WHERE a = b */
@Test
public void testOptionMakeNotDepInline4() {
    // $NON-NLS-1$
    GroupSymbol g1 = new GroupSymbol("db.g1");
    // $NON-NLS-1$ //$NON-NLS-2$
    GroupSymbol g2 = new GroupSymbol("c", "db.g2");
    // $NON-NLS-1$
    ElementSymbol a = new ElementSymbol("a");
    // $NON-NLS-1$
    ElementSymbol b = new ElementSymbol("b");
    CompareCriteria crit = new CompareCriteria(a, CompareCriteria.EQ, b);
    From from = new From();
    FromClause clause = new UnaryFromClause(g1);
    clause.setMakeNotDep(true);
    from.addClause(clause);
    FromClause clause1 = new UnaryFromClause(g2);
    clause1.setMakeNotDep(true);
    from.addClause(clause1);
    Select select = new Select();
    select.addSymbol(a);
    Query query = new Query();
    query.setSelect(select);
    query.setFrom(from);
    query.setCriteria(crit);
    // $NON-NLS-1$
    TestParser.helpTest(// $NON-NLS-1$
    "Select a From db.g1 MAKENOTDEP, db.g2 AS c MAKENOTDEP WHERE a = b", // $NON-NLS-1$
    "SELECT a FROM /*+ MAKENOTDEP */ db.g1, /*+ MAKENOTDEP */ db.g2 AS c WHERE a = b", query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 92 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestOptionsAndHints method testOptionNoCache1.

@Test
public void testOptionNoCache1() {
    // $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();
    option.setNoCache(true);
    // $NON-NLS-1$
    option.addNoCacheGroup("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 nocache a.b.c", // $NON-NLS-1$
    "SELECT a FROM db.g OPTION NOCACHE a.b.c", query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 93 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestOptionsAndHints method testOptionMakeDependent2.

/*+* Select a From db.g Option makedep a.b.c, d.e.f showplan */
@Test
public void testOptionMakeDependent2() {
    // $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");
    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", // $NON-NLS-1$
    "SELECT a FROM db.g OPTION MAKEDEP a.b.c, d.e.f", query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 94 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol 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);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 95 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol in project teiid by teiid.

the class TestOptionsAndHints method testOptionMakeNotDepInline1.

/*+* Select a From db.g1 JOIN db.g2 MAKENOTDEP ON a = b */
@Test
public void testOptionMakeNotDepInline1() {
    // $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().setMakeNotDep(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 MAKENOTDEP ON a = b", // $NON-NLS-1$
    "SELECT a FROM db.g1 INNER JOIN /*+ MAKENOTDEP */ db.g2 ON a = b", query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)299 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)146 Test (org.junit.Test)108 ArrayList (java.util.ArrayList)92 MultipleElementSymbol (org.teiid.query.sql.symbol.MultipleElementSymbol)59 Expression (org.teiid.query.sql.symbol.Expression)52 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)50 Constant (org.teiid.query.sql.symbol.Constant)48 List (java.util.List)43 HashSet (java.util.HashSet)32 Query (org.teiid.query.sql.lang.Query)31 From (org.teiid.query.sql.lang.From)29 SymbolMap (org.teiid.query.sql.util.SymbolMap)29 Select (org.teiid.query.sql.lang.Select)26 Criteria (org.teiid.query.sql.lang.Criteria)22 TempMetadataID (org.teiid.query.metadata.TempMetadataID)21 LinkedList (java.util.LinkedList)20 Command (org.teiid.query.sql.lang.Command)20 Set (java.util.Set)17 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)17