Search in sources :

Example 1 with OrderByItem

use of org.apache.olingo.server.api.uri.queryoption.OrderByItem 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

OrderByItem (org.apache.olingo.server.api.uri.queryoption.OrderByItem)1 AliasSymbol (org.teiid.query.sql.symbol.AliasSymbol)1 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)1 Expression (org.teiid.query.sql.symbol.Expression)1