}
if (!(command instanceof QueryExpression)) {
return null;
}
QueryExpression queryCommand = (QueryExpression)command;
if (queryCommand.getLimit() == null) {
return null;
}
Limit limit = queryCommand.getLimit();
queryCommand.setLimit(null);
List<Object> parts = new ArrayList<Object>();
parts.add("SELECT "); //$NON-NLS-1$
/*
* if all of the columns are aliased, assume that names matter - it actually only seems to matter for
* the first query of a set op when there is a order by. Rather than adding logic to traverse up,
* we just use the projected names
*/
boolean allAliased = true;
for (DerivedColumn selectSymbol : queryCommand.getProjectedQuery().getDerivedColumns()) {
if (selectSymbol.getAlias() == null) {
allAliased = false;
break;
}
}
if (allAliased) {
String[] columnNames = queryCommand.getColumnNames();
for (int i = 0; i < columnNames.length; i++) {
if (i > 0) {
parts.add(", "); //$NON-NLS-1$
}
parts.add(columnNames[i]);