use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class AutoGenDataService method createResults.
public static List[] createResults(List symbols, int rowCount, boolean useIntCounter) {
List[] rows = new List[rowCount];
for (int i = 0; i < rowCount; i++) {
List row = new ArrayList();
Iterator iter = symbols.iterator();
while (iter.hasNext()) {
Expression symbol = (Expression) iter.next();
Class type = symbol.getType();
row.add(getValue(type, i, useIntCounter));
}
rows[i] = row;
}
return rows;
}
use of org.teiid.query.sql.symbol.Expression 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;
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class ODataSQLBuilder method visit.
@Override
public void visit(FilterOption info) {
ODataExpressionToSQLVisitor visitor = new ODataExpressionToSQLVisitor(this.context, this.prepared, getUriInfo(), this.metadata, this.odata, this.nameGenerator, this.params, this.parseService);
Expression filter = null;
try {
filter = visitor.getExpression(info.getExpression());
} catch (TeiidException e) {
this.exceptions.add(e);
}
// Here Lambda operation may have joined a table and changed the context.
this.context = visitor.getEntityResource();
this.context.addCriteria(filter);
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class ODataSQLBuilder method buildAggregateQuery.
private void buildAggregateQuery(DocumentNode node, Query outerQuery, ExpandDocumentNode expandResource, OrderBy expandOrder, Query query, EdmNavigationProperty navigationProperty) throws TeiidException {
Select select = query.getSelect();
Array array = new Array(Object.class, new ArrayList<Expression>(select.getSymbols()));
select.getSymbols().clear();
AggregateSymbol symbol = new AggregateSymbol(AggregateSymbol.Type.ARRAY_AGG.name(), false, array);
select.addSymbol(symbol);
symbol.setOrderBy(expandOrder);
Criteria crit = node.buildJoinCriteria(expandResource, navigationProperty);
if (crit != null) {
query.setCriteria(Criteria.combineCriteria(crit, query.getCriteria()));
}
// else assertion error?
expandResource.setColumnIndex(outerQuery.getSelect().getCount() + 1);
ScalarSubquery agg = new ScalarSubquery(query);
SubqueryHint subqueryHint = new SubqueryHint();
subqueryHint.setMergeJoin(true);
agg.setSubqueryHint(subqueryHint);
outerQuery.getSelect().addSymbol(agg);
}
use of org.teiid.query.sql.symbol.Expression in project teiid by teiid.
the class TestJoinOptimization method helpTestNullDependent.
private void helpTestNullDependent(String expressionSQL, boolean dependent) throws QueryParserException, QueryResolverException, QueryMetadataException, TeiidComponentException {
List<GroupSymbol> innerGroups = new ArrayList<GroupSymbol>();
// $NON-NLS-1$
innerGroups.add(new GroupSymbol("pm1.g1"));
Expression expr = QueryParser.getQueryParser().parseExpression(expressionSQL);
ResolverVisitor.resolveLanguageObject(expr, RealMetadataFactory.example1Cached());
assertEquals(dependent, JoinUtil.isNullDependent(RealMetadataFactory.example1Cached(), innerGroups, expr));
}
Aggregations