Search in sources :

Example 21 with MultipleElementSymbol

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

the class AbstractSymbolMappingVisitor method visit.

/**
 * Swap each ElementSymbol referenced by AllInGroupSymbol
 * @param obj Object to remap
 */
public void visit(MultipleElementSymbol obj) {
    List<ElementSymbol> oldSymbols = obj.getElementSymbols();
    if (oldSymbols != null && oldSymbols.size() > 0) {
        List<ElementSymbol> newSymbols = new ArrayList<ElementSymbol>(oldSymbols.size());
        Iterator<ElementSymbol> iter = oldSymbols.iterator();
        while (iter.hasNext()) {
            ElementSymbol es = iter.next();
            ElementSymbol mappedSymbol = getMappedElement(es);
            newSymbols.add(mappedSymbol);
        }
        obj.setElementSymbols(newSymbols);
    }
    if (obj.getGroup() == null) {
        return;
    }
    obj.setGroup(getMappedGroup(obj.getGroup()));
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) ArrayList(java.util.ArrayList)

Example 22 with MultipleElementSymbol

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

the class TestRulePlaceAccess method testAddAccessPatterns2.

/**
 * Tests that any access patterns (a Collection of Collections of
 * Object element ids) for a physical group will be found and added
 * as a property of an ACCESS node.
 */
public void testAddAccessPatterns2() throws Exception {
    Query query = new Query();
    From from = new From();
    // $NON-NLS-1$
    GroupSymbol group = new GroupSymbol("pm4.g2");
    from.addGroup(group);
    query.setFrom(from);
    Select select = new Select();
    select.addSymbol(new MultipleElementSymbol());
    query.setSelect(select);
    // $NON-NLS-1$
    group.setMetadataID(METADATA.getGroupID("pm4.g2"));
    PlanNode n1 = NodeFactory.getNewNode(NodeConstants.Types.ACCESS);
    n1.setProperty(NodeConstants.Info.ATOMIC_REQUEST, query);
    n1.addGroup(group);
    RulePlaceAccess.addAccessPatternsProperty(n1, METADATA);
    Collection accessPatterns = (Collection) n1.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
    assertNotNull(accessPatterns);
    // $NON-NLS-1$
    assertTrue("Expected two access patterns, got " + accessPatterns.size(), accessPatterns.size() == 2);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) PlanNode(org.teiid.query.optimizer.relational.plantree.PlanNode) Query(org.teiid.query.sql.lang.Query) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) Select(org.teiid.query.sql.lang.Select) Collection(java.util.Collection) From(org.teiid.query.sql.lang.From)

Example 23 with MultipleElementSymbol

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

the class TestLimitParsing method testSetQueryLimit.

@Test
public void testSetQueryLimit() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    SetQuery setQuery = new SetQuery(Operation.UNION, true, query, query);
    setQuery.setLimit(new Limit(new Reference(0), new Reference(1)));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a union all Select * from a limit ?,?", "SELECT * FROM a UNION ALL SELECT * FROM a LIMIT ?, ?", setQuery);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) SetQuery(org.teiid.query.sql.lang.SetQuery) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Reference(org.teiid.query.sql.symbol.Reference) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Example 24 with MultipleElementSymbol

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

the class TestLimitParsing method testLimit.

@Test
public void testLimit() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    query.setLimit(new Limit(null, new Constant(new Integer(100))));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a limit 100", "SELECT * FROM a LIMIT 100", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) 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) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Example 25 with MultipleElementSymbol

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

the class TestLimitParsing method testOffset.

@Test
public void testOffset() {
    Query query = new Query();
    Select select = new Select(Arrays.asList(new MultipleElementSymbol()));
    // $NON-NLS-1$
    From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a"))));
    query.setSelect(select);
    query.setFrom(from);
    query.setLimit(new Limit(new Reference(0), null));
    // $NON-NLS-1$ //$NON-NLS-2$
    helpTest("Select * from a offset ? rows", "SELECT * FROM a OFFSET ? ROWS", query);
}
Also used : MultipleElementSymbol(org.teiid.query.sql.symbol.MultipleElementSymbol) Query(org.teiid.query.sql.lang.Query) SetQuery(org.teiid.query.sql.lang.SetQuery) UnaryFromClause(org.teiid.query.sql.lang.UnaryFromClause) Reference(org.teiid.query.sql.symbol.Reference) Select(org.teiid.query.sql.lang.Select) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) From(org.teiid.query.sql.lang.From) Limit(org.teiid.query.sql.lang.Limit) Test(org.junit.Test)

Aggregations

MultipleElementSymbol (org.teiid.query.sql.symbol.MultipleElementSymbol)41 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)29 Test (org.junit.Test)27 Select (org.teiid.query.sql.lang.Select)19 Query (org.teiid.query.sql.lang.Query)14 From (org.teiid.query.sql.lang.From)12 SetQuery (org.teiid.query.sql.lang.SetQuery)11 ArrayList (java.util.ArrayList)10 Limit (org.teiid.query.sql.lang.Limit)10 UnaryFromClause (org.teiid.query.sql.lang.UnaryFromClause)10 Constant (org.teiid.query.sql.symbol.Constant)7 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)7 Reference (org.teiid.query.sql.symbol.Reference)5 List (java.util.List)3 Expression (org.teiid.query.sql.symbol.Expression)2 Collection (java.util.Collection)1 QueryValidatorException (org.teiid.api.exception.query.QueryValidatorException)1 MultiSourceElement (org.teiid.dqp.internal.process.multisource.MultiSourceElement)1 TempMetadataID (org.teiid.query.metadata.TempMetadataID)1 PlanNode (org.teiid.query.optimizer.relational.plantree.PlanNode)1