Search in sources :

Example 56 with ElementSymbol

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

the class TestSelect method testGetProjectedWithStar.

public void testGetProjectedWithStar() {
    List symbols = new ArrayList();
    // $NON-NLS-1$
    symbols.add(new ElementSymbol("a"));
    // $NON-NLS-1$
    symbols.add(new ElementSymbol("b"));
    Select select = new Select();
    MultipleElementSymbol all = new MultipleElementSymbol();
    all.setElementSymbols(symbols);
    select.addSymbol(all);
    List projectedSymbols = select.getProjectedSymbols();
    // $NON-NLS-1$
    assertEquals("Did not get correct list for select *: ", symbols, projectedSymbols);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) ArrayList(java.util.ArrayList) Select(org.teiid.query.sql.lang.Select) List(java.util.List) ArrayList(java.util.ArrayList)

Example 57 with ElementSymbol

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

the class TestSetCriteria method sample1.

public static final SetCriteria sample1() {
    SetCriteria c1 = new SetCriteria();
    // $NON-NLS-1$
    c1.setExpression(new ElementSymbol("e1"));
    List vals = new ArrayList();
    // $NON-NLS-1$
    vals.add(new Constant("a"));
    // $NON-NLS-1$
    vals.add(new Constant("b"));
    c1.setValues(vals);
    return c1;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 58 with ElementSymbol

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

the class TestSetCriteria method testNonHashableClone.

@Test
public void testNonHashableClone() {
    SetCriteria c1 = new SetCriteria();
    // $NON-NLS-1$
    c1.setExpression(new ElementSymbol("e1"));
    TreeSet vals = new TreeSet();
    vals.add(new Constant(BigDecimal.valueOf(1.1)));
    vals.add(new Constant(BigDecimal.valueOf(1.2)));
    c1.setValues(vals);
    c1.setAllConstants(true);
    SetCriteria c2 = (SetCriteria) c1.clone();
    assertTrue(c2.getValues() instanceof TreeSet);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TreeSet(java.util.TreeSet) Constant(org.teiid.query.sql.symbol.Constant) Test(org.junit.Test)

Example 59 with ElementSymbol

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

the class TestSetCriteria method sample2.

public static final SetCriteria sample2() {
    SetCriteria c1 = new SetCriteria();
    // $NON-NLS-1$
    c1.setExpression(new ElementSymbol("e2"));
    List vals = new ArrayList();
    // $NON-NLS-1$
    vals.add(new Constant("c"));
    // $NON-NLS-1$
    vals.add(new Constant("d"));
    c1.setValues(vals);
    return c1;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 60 with ElementSymbol

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

the class TestSetQuery method test2.

public void test2() {
    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.INTERSECT);
    sq.setAll(false);
    sq.setLeftQuery(q1);
    sq.setRightQuery(q2);
    assertEquals(// $NON-NLS-1$
    "Query combiner string doesn't match expected: ", // $NON-NLS-1$
    "SELECT x FROM g INTERSECT SELECT y FROM h", sq.toString());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol)

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