Search in sources :

Example 1 with Ordering

use of org.teiid.language.SortSpecification.Ordering in project teiid by teiid.

the class LanguageBridgeFactory method translate.

public org.teiid.language.OrderBy translate(OrderBy orderBy, boolean set) {
    if (orderBy == null) {
        return null;
    }
    List<OrderByItem> items = orderBy.getOrderByItems();
    List<SortSpecification> translatedItems = new ArrayList<SortSpecification>();
    for (int i = 0; i < items.size(); i++) {
        Expression symbol = items.get(i).getSymbol();
        Ordering direction = items.get(i).isAscending() ? Ordering.ASC : Ordering.DESC;
        SortSpecification orderByItem = null;
        if (!set && (items.get(i).isUnrelated() || symbol instanceof ElementSymbol)) {
            orderByItem = new SortSpecification(direction, translate(symbol));
        } else {
            orderByItem = new SortSpecification(direction, new ColumnReference(null, Symbol.getShortName(((Symbol) symbol).getOutputName()), null, symbol.getType()));
        }
        orderByItem.setNullOrdering(items.get(i).getNullOrdering());
        translatedItems.add(orderByItem);
    }
    return new org.teiid.language.OrderBy(translatedItems);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) OrderBy(org.teiid.query.sql.lang.OrderBy) ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) AggregateSymbol(org.teiid.query.sql.symbol.AggregateSymbol) Symbol(org.teiid.query.sql.symbol.Symbol) GroupSymbol(org.teiid.query.sql.symbol.GroupSymbol) AliasSymbol(org.teiid.query.sql.symbol.AliasSymbol) ExpressionSymbol(org.teiid.query.sql.symbol.ExpressionSymbol) SearchedCaseExpression(org.teiid.query.sql.symbol.SearchedCaseExpression) Expression(org.teiid.query.sql.symbol.Expression) Ordering(org.teiid.language.SortSpecification.Ordering)

Aggregations

Ordering (org.teiid.language.SortSpecification.Ordering)1 OrderBy (org.teiid.query.sql.lang.OrderBy)1 AggregateSymbol (org.teiid.query.sql.symbol.AggregateSymbol)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 ExpressionSymbol (org.teiid.query.sql.symbol.ExpressionSymbol)1 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)1 SearchedCaseExpression (org.teiid.query.sql.symbol.SearchedCaseExpression)1 Symbol (org.teiid.query.sql.symbol.Symbol)1