Search in sources :

Example 86 with ElementSymbol

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

the class TestResolver method testStringConversion3.

// special test for both sides are String
@Test
public void testStringConversion3() {
    // Expected left expression
    // $NON-NLS-1$
    ElementSymbol e1 = new ElementSymbol("pm3.g1.e1");
    e1.setType(DataTypeManager.DefaultDataClasses.STRING);
    // Expected right expression
    // $NON-NLS-1$
    Constant e2 = new Constant("2003-02-27");
    // Expected criteria
    CompareCriteria expected = new CompareCriteria();
    expected.setLeftExpression(e1);
    expected.setOperator(CompareCriteria.EQ);
    expected.setRightExpression(e2);
    // Resolve the query and check against expected objects
    // $NON-NLS-1$
    CompareCriteria actual = (CompareCriteria) helpResolveCriteria("pm3.g1.e1='2003-02-27'");
    // if (! actual.getLeftExpression().equals(expected.getLeftExpression())) {
    // System.out.println("left exprs not equal");
    // } else if (!actual.getRightExpression().equals(expected.getRightExpression())) {
    // System.out.println("right exprs not equal");
    // }
    // $NON-NLS-1$
    assertEquals("Did not match expected criteria", expected, actual);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Constant(org.teiid.query.sql.symbol.Constant) Test(org.junit.Test)

Example 87 with ElementSymbol

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

the class TestResolver method testExecProjectedSymbols.

@Test
public void testExecProjectedSymbols() {
    // $NON-NLS-1$
    String query = "exec pm1.sq1()";
    StoredProcedure proc = (StoredProcedure) helpResolve(query);
    List<Expression> projected = proc.getProjectedSymbols();
    assertEquals(2, projected.size());
    for (Iterator<Expression> i = projected.iterator(); i.hasNext(); ) {
        ElementSymbol symbol = (ElementSymbol) i.next();
        assertNotNull(symbol.getGroupSymbol());
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Expression(org.teiid.query.sql.symbol.Expression) Test(org.junit.Test)

Example 88 with ElementSymbol

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

the class TestOrderByRewrite method helpCheckElements.

private void helpCheckElements(OrderBy langObj, String[] elementNames, String[] elementIDs) {
    List<ElementSymbol> elements = new ArrayList<ElementSymbol>();
    for (Iterator<Expression> i = langObj.getSortKeys().iterator(); i.hasNext(); ) {
        ElementCollectorVisitor.getElements(i.next(), elements);
    }
    // $NON-NLS-1$
    assertEquals("Wrong number of elements: ", elementNames.length, elements.size());
    for (int i = 0; i < elements.size(); i++) {
        ElementSymbol symbol = elements.get(i);
        // $NON-NLS-1$
        assertEquals("Element name does not match: ", elementNames[i].toUpperCase(), symbol.getName().toUpperCase());
        Column elementID = (Column) symbol.getMetadataID();
        // $NON-NLS-1$ //$NON-NLS-2$
        assertNotNull("ElementSymbol " + symbol + " was not resolved and has no metadataID", elementID);
        // $NON-NLS-1$
        assertEquals("ElementID name does not match: ", elementIDs[i].toUpperCase(), elementID.getFullName().toUpperCase());
    }
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Expression(org.teiid.query.sql.symbol.Expression) Column(org.teiid.metadata.Column) ArrayList(java.util.ArrayList)

Example 89 with ElementSymbol

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

the class TestAccessNode method testShouldExecuteUpdate.

@Test
public void testShouldExecuteUpdate() throws Exception {
    Update update = new Update();
    // $NON-NLS-1$
    update.setGroup(new GroupSymbol("test"));
    // $NON-NLS-1$ //$NON-NLS-2$
    update.addChange(new ElementSymbol("e1"), new Constant("1"));
    assertTrue(RelationalNodeUtil.shouldExecute(update, false));
    update.setChangeList(new SetClauseList());
    assertFalse(RelationalNodeUtil.shouldExecute(update, false));
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Constant(org.teiid.query.sql.symbol.Constant) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) SetClauseList(org.teiid.query.sql.lang.SetClauseList) Update(org.teiid.query.sql.lang.Update) Test(org.junit.Test)

Example 90 with ElementSymbol

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

the class TestDependentCriteriaProcessor method testNegatedSetCriteria.

@Test
public void testNegatedSetCriteria() throws Exception {
    DependentAccessNode dan = new DependentAccessNode(0);
    // $NON-NLS-1$
    SetCriteria sc = new SetCriteria(new ElementSymbol("e1"), Arrays.asList(new Constant(1), new Constant(2)));
    sc.setAllConstants(true);
    sc.negate();
    DependentCriteriaProcessor dcp = new DependentCriteriaProcessor(1, -1, dan, sc);
    Criteria result = dcp.prepareCriteria();
    assertEquals(sc, result);
    assertFalse(dcp.hasNextCommand());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) 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) Test(org.junit.Test)

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