Skip to content

Commit

Permalink
Minor formatter cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed May 28, 2014
1 parent ce6cf9f commit 8c571c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static Function<Expression, String> expressionFormatterFunction()
@Override
public String apply(Expression input)
{
return ExpressionFormatter.formatExpression(input);
return formatExpression(input);
}
};
}
Expand Down Expand Up @@ -162,7 +162,7 @@ protected String visitDoubleLiteral(DoubleLiteral node, Void context)
@Override
protected String visitGenericLiteral(GenericLiteral node, Void context)
{
return "" + node.getType() + " '" + node.getValue() + "'";
return node.getType() + " '" + node.getValue() + "'";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import com.facebook.presto.sql.tree.WithQuery;
import com.google.common.base.Joiner;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;

import java.util.ArrayList;
import java.util.Iterator;
Expand All @@ -60,6 +59,8 @@
import static com.facebook.presto.sql.ExpressionFormatter.formatSortItems;
import static com.facebook.presto.sql.ExpressionFormatter.formatStringLiteral;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.collect.Iterables.transform;

public final class SqlFormatter
{
Expand Down Expand Up @@ -158,7 +159,7 @@ protected Void visitQuerySpecification(QuerySpecification node, Integer indent)
}
else {
builder.append(' ');
process(Iterables.getOnlyElement(node.getFrom()), indent);
process(getOnlyElement(node.getFrom()), indent);
}
}

Expand All @@ -170,7 +171,7 @@ protected Void visitQuerySpecification(QuerySpecification node, Integer indent)
}

if (!node.getGroupBy().isEmpty()) {
append(indent, "GROUP BY " + Joiner.on(", ").join(Iterables.transform(node.getGroupBy(), expressionFormatterFunction())))
append(indent, "GROUP BY " + Joiner.on(", ").join(transform(node.getGroupBy(), expressionFormatterFunction())))
.append('\n');
}

Expand Down Expand Up @@ -212,7 +213,7 @@ protected Void visitSelect(Select node, Integer indent)
}
else {
builder.append(' ');
process(Iterables.getOnlyElement(node.getSelectItems()), indent);
process(getOnlyElement(node.getSelectItems()), indent);
}

builder.append('\n');
Expand Down Expand Up @@ -343,7 +344,7 @@ protected Void visitValues(Values node, Integer indent)
protected Void visitRow(Row node, Integer indent)
{
builder.append('(')
.append(Joiner.on(", ").join(Iterables.transform(node.getItems(), expressionFormatterFunction())))
.append(Joiner.on(", ").join(transform(node.getItems(), expressionFormatterFunction())))
.append(')');

return null;
Expand Down

0 comments on commit 8c571c3

Please sign in to comment.