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()));
}
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);
}
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);
}
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);
}
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);
}
Aggregations