Search in sources :

Example 81 with GroupSymbol

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

the class TestOptionsAndHints method testDepOptions2.

@Test
public void testDepOptions2() {
    // $NON-NLS-1$
    GroupSymbol a = new GroupSymbol("a");
    // $NON-NLS-1$
    GroupSymbol b = new GroupSymbol("b");
    // $NON-NLS-1$
    ElementSymbol x = new ElementSymbol("a.x", true);
    // $NON-NLS-1$
    ElementSymbol y = new ElementSymbol("b.y", true);
    // $NON-NLS-1$
    Criteria criteria = new CompareCriteria(x, CompareCriteria.EQ, new Function("func", new Expression[] { y }));
    JoinPredicate predicate = new JoinPredicate(new UnaryFromClause(a), new UnaryFromClause(b), JoinType.JOIN_INNER, Arrays.asList(new Object[] { criteria }));
    From from = new From(Arrays.asList(predicate));
    predicate.getLeftClause().setMakeNotDep(true);
    predicate.getRightClause().setMakeDep(true);
    Select select = new Select(Arrays.asList(x, y));
    Query query = new Query(select, from, null, null, null, null, null);
    // $NON-NLS-1$
    TestParser.helpTest(// $NON-NLS-1$
    "Select a.x, b.y From a MAKENOTDEP INNER JOIN b MAKEDEP ON a.x = func(b.y)", // $NON-NLS-1$
    "SELECT a.x, b.y FROM /*+ MAKENOTDEP */ a INNER JOIN /*+ MAKEDEP */ b ON a.x = func(b.y)", query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Function(org.teiid.query.sql.symbol.Function) Expression(org.teiid.query.sql.symbol.Expression) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 82 with GroupSymbol

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

the class TestOptionsAndHints method testOptionMakeDepInline4.

/*+* Select a From db.g1 MAKEDEP, db.g2 MAKEDEP WHERE a = b */
@Test
public void testOptionMakeDepInline4() {
    // $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.setMakeDep(true);
    from.addClause(clause);
    FromClause clause1 = new UnaryFromClause(g2);
    clause1.setMakeDep(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 MAKEDEP, db.g2 AS c MAKEDEP WHERE a = b", // $NON-NLS-1$
    "SELECT a FROM /*+ MAKEDEP */ db.g1, /*+ MAKEDEP */ 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 83 with GroupSymbol

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

the class TestOptionsAndHints method testOptionMakeNotDepInline3.

/*+* Select a From (db.g1 MAKENOTDEP JOIN db.g2 ON a = b) LEFT OUTER JOIN db.g3 MAKENOTDEP ON a = c */
@Test
public void testOptionMakeNotDepInline3() {
    // $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().setMakeNotDep(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().setMakeNotDep(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 MAKENOTDEP JOIN db.g2 ON a = b) LEFT OUTER JOIN db.g3 MAKENOTDEP ON a = c", // $NON-NLS-1$
    "SELECT a FROM (/*+ MAKENOTDEP */ db.g1 INNER JOIN db.g2 ON a = b) LEFT OUTER JOIN /*+ MAKENOTDEP */ db.g3 ON a = 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) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 84 with GroupSymbol

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

Example 85 with GroupSymbol

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

the class TestOptionsAndHints method testOptionNoCache3.

// related to defect 14423
@Test
public void testOptionNoCache3() {
    // $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);
    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", // $NON-NLS-1$
    "SELECT a FROM db.g OPTION NOCACHE", 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)

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