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;
}