Search in sources :

Example 31 with MultipleElementSymbol

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

the class TestOptionsAndHints method testOptionalFromClause3.

@Test
public void testOptionalFromClause3() {
    // $NON-NLS-1$
    String sql = "SELECT * FROM /*+ optional */ t1 AS a, 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$ //$NON-NLS-2$
    ufc.setGroup(new GroupSymbol("a", "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 AS a, t2", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 32 with MultipleElementSymbol

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

the class TestOptionsAndHints method testCacheScope.

@Test
public void testCacheScope() {
    // $NON-NLS-1$
    String sql = "/*+ cache(pref_mem scope:session) */ 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.setScope(Scope.SESSION);
    hint.setPrefersMemory(true);
    query.setCacheHint(hint);
    // $NON-NLS-1$
    TestParser.helpTest(sql, "/*+ cache(pref_mem scope:SESSION) */ SELECT * FROM t1", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 33 with MultipleElementSymbol

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

the class TestOptionsAndHints method testOptionalFromClause4.

@Test
public void testOptionalFromClause4() {
    // $NON-NLS-1$
    String sql = "SELECT * FROM t1, /*+ optional */ t2 as a";
    Query query = new Query();
    Select select = new Select();
    select.addSymbol(new MultipleElementSymbol());
    query.setSelect(select);
    From from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("t1"));
    UnaryFromClause ufc = new UnaryFromClause();
    // $NON-NLS-1$ //$NON-NLS-2$
    ufc.setGroup(new GroupSymbol("a", "t2"));
    ufc.setOptional(true);
    from.addClause(ufc);
    query.setFrom(from);
    // $NON-NLS-1$
    TestParser.helpTest(sql, "SELECT * FROM t1, /*+ optional */ t2 AS a", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 34 with MultipleElementSymbol

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

the class TestOptionsAndHints method testOptionalFromClause1_2.

@Test
public void testOptionalFromClause1_2() {
    // $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);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Example 35 with MultipleElementSymbol

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

the class TestOptionsAndHints method testOptionalFromClause1_1.

@Test
public void testOptionalFromClause1_1() {
    // $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);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Test(org.junit.Test)

Aggregations

MultipleElementSymbol (org.teiid.query.sql.symbol.MultipleElementSymbol)41 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)29 Test (org.junit.Test)27 Select (org.teiid.query.sql.lang.Select)19 Query (org.teiid.query.sql.lang.Query)14 From (org.teiid.query.sql.lang.From)12 SetQuery (org.teiid.query.sql.lang.SetQuery)11 ArrayList (java.util.ArrayList)10 Limit (org.teiid.query.sql.lang.Limit)10 UnaryFromClause (org.teiid.query.sql.lang.UnaryFromClause)10 Constant (org.teiid.query.sql.symbol.Constant)7 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)7 Reference (org.teiid.query.sql.symbol.Reference)5 List (java.util.List)3 Expression (org.teiid.query.sql.symbol.Expression)2 Collection (java.util.Collection)1 QueryValidatorException (org.teiid.api.exception.query.QueryValidatorException)1 MultiSourceElement (org.teiid.dqp.internal.process.multisource.MultiSourceElement)1 TempMetadataID (org.teiid.query.metadata.TempMetadataID)1 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)1