Search in sources :

Example 61 with ElementSymbol

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

the class TestSetQuery method sample1.

// ################################## TEST HELPERS ################################
/**
 * SELECT x FROM g UNION ALL SELECT y FROM h
 */
public static final SetQuery sample1() {
    Query q1 = new Query();
    Select select = new Select();
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("x"));
    q1.setSelect(select);
    From from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("g"));
    q1.setFrom(from);
    Query q2 = new Query();
    select = new Select();
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("y"));
    q2.setSelect(select);
    from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("h"));
    q2.setFrom(from);
    SetQuery sq = new SetQuery(Operation.UNION);
    sq.setLeftQuery(q1);
    sq.setRightQuery(q2);
    return sq;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol)

Example 62 with ElementSymbol

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

the class TestSetQuery method testQuery.

public void testQuery() {
    Query q = sample3();
    List projList = new ArrayList();
    // $NON-NLS-1$
    projList.add(new ElementSymbol("xml"));
    assertEquals(// $NON-NLS-1$
    "result is not as expected.", projList, q.getProjectedSymbols());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 63 with ElementSymbol

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

the class TestSubqueryFromClause method example1.

// ################################## HELPERS ################################
public static SubqueryFromClause example1() {
    Query query = new Query();
    Select select = new Select();
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("a"));
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("b"));
    query.setSelect(select);
    From from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("m.g"));
    query.setFrom(from);
    CompareCriteria crit = new CompareCriteria();
    // $NON-NLS-1$
    crit.setLeftExpression(new ElementSymbol("a"));
    crit.setRightExpression(new Constant(new Integer(5)));
    crit.setOperator(CompareCriteria.EQ);
    query.setCriteria(crit);
    // $NON-NLS-1$
    return new SubqueryFromClause("temp", query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Query(org.teiid.query.sql.lang.Query) Constant(org.teiid.query.sql.symbol.Constant) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) SubqueryFromClause(org.teiid.query.sql.lang.SubqueryFromClause)

Example 64 with ElementSymbol

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

the class TestSubquerySetCriteria method example1.

public static SubquerySetCriteria example1() {
    Query query = new Query();
    Select select = new Select();
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("a"));
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("b"));
    query.setSelect(select);
    From from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("m.g"));
    query.setFrom(from);
    CompareCriteria crit = new CompareCriteria();
    // $NON-NLS-1$
    crit.setLeftExpression(new ElementSymbol("a"));
    crit.setRightExpression(new Constant(new Integer(5)));
    crit.setOperator(CompareCriteria.EQ);
    query.setCriteria(crit);
    // $NON-NLS-1$
    return new SubquerySetCriteria(new ElementSymbol("temp"), query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Query(org.teiid.query.sql.lang.Query) Constant(org.teiid.query.sql.symbol.Constant) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) SubquerySetCriteria(org.teiid.query.sql.lang.SubquerySetCriteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria)

Example 65 with ElementSymbol

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

the class TestSubquerySetCriteria method example3.

public static SubquerySetCriteria example3() {
    Query query = new Query();
    Select select = new Select();
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("a"));
    // $NON-NLS-1$
    select.addSymbol(new ElementSymbol("b"));
    query.setSelect(select);
    From from = new From();
    // $NON-NLS-1$
    from.addGroup(new GroupSymbol("m.g"));
    query.setFrom(from);
    CompareCriteria crit = new CompareCriteria();
    // $NON-NLS-1$
    crit.setLeftExpression(new ElementSymbol("a"));
    crit.setRightExpression(new Constant(new Integer(5)));
    crit.setOperator(CompareCriteria.EQ);
    query.setCriteria(crit);
    // $NON-NLS-1$
    return new SubquerySetCriteria(new ElementSymbol("temp2"), query);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Query(org.teiid.query.sql.lang.Query) Constant(org.teiid.query.sql.symbol.Constant) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) SubquerySetCriteria(org.teiid.query.sql.lang.SubquerySetCriteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria)

Aggregations

ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)417 ArrayList (java.util.ArrayList)165 Test (org.junit.Test)157 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)148 Expression (org.teiid.query.sql.symbol.Expression)104 List (java.util.List)103 Constant (org.teiid.query.sql.symbol.Constant)94 MultipleElementSymbol (org.teiid.query.sql.symbol.MultipleElementSymbol)41 SymbolMap (org.teiid.query.sql.util.SymbolMap)40 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)36 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)29 Map (java.util.Map)28 AggregateSymbol (org.teiid.query.sql.symbol.AggregateSymbol)28 Query (org.teiid.query.sql.lang.Query)26 HashMap (java.util.HashMap)25 Select (org.teiid.query.sql.lang.Select)24 BufferManager (org.teiid.common.buffer.BufferManager)22 Criteria (org.teiid.query.sql.lang.Criteria)22 LinkedList (java.util.LinkedList)20 TupleBuffer (org.teiid.common.buffer.TupleBuffer)19