Search in sources :

Example 31 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol 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 32 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol 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 33 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol 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 34 with GroupSymbol

use of org.teiid.query.sql.symbol.GroupSymbol 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)

Example 35 with GroupSymbol

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

the class TestLoopStatement method query1.

// ################################## TEST HELPERS ################################
public static final Query query1() {
    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);
    return q1;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Query(org.teiid.query.sql.lang.Query) TestSetQuery(org.teiid.query.sql.lang.TestSetQuery) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From)

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