Search in sources :

Example 11 with SetCriteria

use of org.teiid.query.sql.lang.SetCriteria in project teiid by teiid.

the class TestDependentCriteriaProcessor method testEvaluatedSetCriteria.

@Test
public void testEvaluatedSetCriteria() throws Exception {
    DependentAccessNode dan = new DependentAccessNode(0);
    CommandContext cc = new CommandContext();
    dan.setContext(cc);
    List<Reference> references = Arrays.asList(new Reference(1), new Reference(2));
    for (Reference reference : references) {
        cc.getVariableContext().setGlobalValue(reference.getContextSymbol(), 1);
    }
    // $NON-NLS-1$
    SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), references);
    sc.setAllConstants(true);
    DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
    Criteria result = dcp.prepareCriteria();
    // $NON-NLS-1$
    assertEquals(new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(1)), result);
    assertFalse(dcp.hasNextCommand());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) CommandContext(org.teiid.query.util.CommandContext) Reference(org.teiid.query.sql.symbol.Reference) Constant(org.teiid.query.sql.symbol.Constant) SetCriteria(org.teiid.query.sql.lang.SetCriteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) SetCriteria(org.teiid.query.sql.lang.SetCriteria) Criteria(org.teiid.query.sql.lang.Criteria) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria) Test(org.junit.Test)

Example 12 with SetCriteria

use of org.teiid.query.sql.lang.SetCriteria in project teiid by teiid.

the class TestExpressionMappingVisitor method testSetCriteria.

@Test
public void testSetCriteria() {
    // $NON-NLS-1$
    ElementSymbol e1 = new ElementSymbol("e1");
    // $NON-NLS-1$
    ElementSymbol e2 = new ElementSymbol("e2");
    // $NON-NLS-1$
    Constant c1 = new Constant("xyz");
    // $NON-NLS-1$
    Constant c2 = new Constant("abc");
    // $NON-NLS-1$
    Constant c3 = new Constant("def");
    List<Expression> values = new ArrayList<Expression>();
    values.add(c1);
    values.add(c2);
    List<Expression> mappedValues = new ArrayList<Expression>();
    mappedValues.add(c1);
    mappedValues.add(c3);
    Map<Expression, Expression> map = new HashMap<Expression, Expression>();
    map.put(e1, e2);
    map.put(c2, c3);
    SetCriteria before = new SetCriteria(e1, values);
    SetCriteria after = new SetCriteria(e2, mappedValues);
    helpTest(before, map, after);
}
Also used : HashMap(java.util.HashMap) SetCriteria(org.teiid.query.sql.lang.SetCriteria) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

SetCriteria (org.teiid.query.sql.lang.SetCriteria)12 Criteria (org.teiid.query.sql.lang.Criteria)8 CompareCriteria (org.teiid.query.sql.lang.CompareCriteria)7 Test (org.junit.Test)6 Constant (org.teiid.query.sql.symbol.Constant)6 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)4 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 AndOr (org.teiid.language.AndOr)2 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)2 CompoundCriteria (org.teiid.query.sql.lang.CompoundCriteria)2 DependentSetCriteria (org.teiid.query.sql.lang.DependentSetCriteria)2 IsNullCriteria (org.teiid.query.sql.lang.IsNullCriteria)2 Expression (org.teiid.query.sql.symbol.Expression)2 Reference (org.teiid.query.sql.symbol.Reference)2 HashMap (java.util.HashMap)1 Expression (org.teiid.language.Expression)1 In (org.teiid.language.In)1 LanguageObject (org.teiid.query.sql.LanguageObject)1 LanguageVisitor (org.teiid.query.sql.LanguageVisitor)1