use of org.teiid.language.OrderBy in project teiid by teiid.
the class TestSetQueryImpl method example3.
public static SetQuery example3() throws Exception {
SetQuery union = example2();
List<SortSpecification> items = new ArrayList<SortSpecification>();
// $NON-NLS-1$
items.add(new SortSpecification(Ordering.ASC, new ColumnReference(null, "nugent", null, DataTypeManager.DefaultDataClasses.STRING)));
OrderBy orderBy = new OrderBy(items);
union.setOrderBy(orderBy);
return union;
}
use of org.teiid.language.OrderBy 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;
}
Aggregations