}
public void visit(OrderBy obj) {
//add/correct aliases if necessary
for (int i = 0; i < obj.getVariableCount(); i++) {
OrderByItem item = obj.getOrderByItems().get(i);
SingleElementSymbol element = item.getSymbol();
if (item.isUnrelated()) {
visitNode(element);
continue;
}
String name = visitor.namingContext.getElementName(element, false);
boolean needsAlias = visitor.namingContext.aliasColumns;
if (name != null) {
Expression expr = SymbolMap.getExpression(element);
if (!(expr instanceof SingleElementSymbol)) {
expr = new ExpressionSymbol(element.getShortName(), expr);
} else if (expr instanceof ElementSymbol) {
needsAlias &= needsAlias(name, (ElementSymbol)expr);
}
if (needsAlias) {
element = new AliasSymbol(element.getShortName(), (SingleElementSymbol)expr);
} else if (expr instanceof ElementSymbol) {
element = (ElementSymbol)expr;
visitNode(element);
}
item.setSymbol(element);
element.setOutputName(name);
}
}
}