Search in sources :

Example 16 with ElementSymbol

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

the class TestInsertImpl method helpExample.

public static org.teiid.query.sql.lang.Insert helpExample(String groupName) {
    GroupSymbol group = TestGroupImpl.helpExample(groupName);
    ArrayList<ElementSymbol> elements = new ArrayList<ElementSymbol>();
    // $NON-NLS-1$
    elements.add(TestElementImpl.helpExample(groupName, "e1"));
    // $NON-NLS-1$
    elements.add(TestElementImpl.helpExample(groupName, "e2"));
    // $NON-NLS-1$
    elements.add(TestElementImpl.helpExample(groupName, "e3"));
    // $NON-NLS-1$
    elements.add(TestElementImpl.helpExample(groupName, "e4"));
    ArrayList<Constant> values = new ArrayList<Constant>();
    values.add(TestLiteralImpl.helpExample(1));
    values.add(TestLiteralImpl.helpExample(2));
    values.add(TestLiteralImpl.helpExample(3));
    values.add(TestLiteralImpl.helpExample(4));
    return new org.teiid.query.sql.lang.Insert(group, elements, values);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Constant(org.teiid.query.sql.symbol.Constant) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) Insert(org.teiid.language.Insert)

Example 17 with ElementSymbol

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

the class TestInsertImpl method helpExample2.

public static org.teiid.query.sql.lang.Insert helpExample2(String groupName) {
    GroupSymbol group = TestGroupImpl.helpExample(groupName);
    ArrayList<ElementSymbol> elements = new ArrayList<ElementSymbol>();
    // $NON-NLS-1$
    elements.add(TestElementImpl.helpExample(groupName, "e1"));
    ArrayList<org.teiid.query.sql.symbol.Expression> values = new ArrayList<org.teiid.query.sql.symbol.Expression>();
    values.add(TestSearchedCaseExpressionImpl.helpExample());
    return new org.teiid.query.sql.lang.Insert(group, elements, values);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Expression(org.teiid.language.Expression) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) ArrayList(java.util.ArrayList) Insert(org.teiid.language.Insert)

Example 18 with ElementSymbol

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

the class TestLikeCriteriaImpl method helpExample.

public static MatchCriteria helpExample(String right, char escape, boolean negated) {
    // $NON-NLS-1$ //$NON-NLS-2$
    ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1");
    MatchCriteria match = new MatchCriteria(e1, new Constant(right), escape);
    match.setNegated(negated);
    return match;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) MatchCriteria(org.teiid.query.sql.lang.MatchCriteria) Constant(org.teiid.query.sql.symbol.Constant)

Example 19 with ElementSymbol

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

the class TestSearchedCaseExpressionImpl method getWhenCriteria.

public static List getWhenCriteria(int criteria) {
    ArrayList list = new ArrayList();
    // $NON-NLS-1$ //$NON-NLS-2$
    ElementSymbol x = TestElementImpl.helpExample("vm1.g1", "e1");
    for (int i = 0; i < criteria; i++) {
        list.add(new CompareCriteria(x, CompareCriteria.EQ, new Constant(new Integer(i))));
    }
    return list;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) Constant(org.teiid.query.sql.symbol.Constant) ArrayList(java.util.ArrayList) CompareCriteria(org.teiid.query.sql.lang.CompareCriteria)

Example 20 with ElementSymbol

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

the class ODataSQLBuilder method processOrderBy.

private OrderBy processOrderBy(OrderBy orderBy, List<OrderByItem> orderByItems, DocumentNode resource) throws TeiidException {
    for (OrderByItem obitem : orderByItems) {
        ODataExpressionToSQLVisitor visitor = new ODataExpressionToSQLVisitor(resource, false, getUriInfo(), this.metadata, this.odata, this.nameGenerator, this.params, this.parseService);
        Expression expr = visitor.getExpression(obitem.getExpression());
        if (expr instanceof ElementSymbol) {
            orderBy.addVariable(expr, !obitem.isDescending());
        } else {
            AliasSymbol alias = new AliasSymbol("_orderByAlias", expr);
            orderBy.addVariable(alias, !obitem.isDescending());
            visitor.getEntityResource().addProjectedColumn(alias, EdmInt32.getInstance(), null, false);
        }
    }
    return orderBy;
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) OrderByItem(org.apache.olingo.server.api.uri.queryoption.OrderByItem) AliasSymbol(org.teiid.query.sql.symbol.AliasSymbol) Expression(org.teiid.query.sql.symbol.Expression)

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