Search in sources :

Example 1 with With

use of org.teiid.language.With in project teiid by teiid.

the class BaseSybaseExecutionFactory method translateCommand.

/**
 * SetQueries don't have a concept of TOP, an inline view is needed.
 */
@Override
public List<?> translateCommand(Command command, ExecutionContext context) {
    if (!(command instanceof SetQuery)) {
        return null;
    }
    SetQuery queryCommand = (SetQuery) command;
    if (queryCommand.getLimit() == null) {
        return null;
    }
    Limit limit = queryCommand.getLimit();
    OrderBy orderBy = queryCommand.getOrderBy();
    queryCommand.setLimit(null);
    queryCommand.setOrderBy(null);
    List<Object> parts = new ArrayList<Object>(6);
    if (queryCommand.getWith() != null) {
        With with = queryCommand.getWith();
        queryCommand.setWith(null);
        parts.add(with);
    }
    // $NON-NLS-1$
    parts.add("SELECT ");
    parts.addAll(translateLimit(limit, context));
    // $NON-NLS-1$
    parts.add(" * FROM (");
    parts.add(queryCommand);
    // $NON-NLS-1$
    parts.add(") AS X");
    if (orderBy != null) {
        // $NON-NLS-1$
        parts.add(" ");
        parts.add(orderBy);
    }
    return parts;
}
Also used : OrderBy(org.teiid.language.OrderBy) SetQuery(org.teiid.language.SetQuery) ArrayList(java.util.ArrayList) LanguageObject(org.teiid.language.LanguageObject) Limit(org.teiid.language.Limit) With(org.teiid.language.With)

Aggregations

ArrayList (java.util.ArrayList)1 LanguageObject (org.teiid.language.LanguageObject)1 Limit (org.teiid.language.Limit)1 OrderBy (org.teiid.language.OrderBy)1 SetQuery (org.teiid.language.SetQuery)1 With (org.teiid.language.With)1