Skip to content

Commit

Permalink
Reuse formatOrderingScheme method
Browse files Browse the repository at this point in the history
  • Loading branch information
losipiuk committed Nov 5, 2024
1 parent b96a481 commit 9949d82
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2071,7 +2071,7 @@ private String formatOrderingScheme(OrderingScheme orderingScheme, int preSorted

private String formatOrderingScheme(OrderingScheme orderingScheme)
{
return formatCollection(orderingScheme.orderBy(), input -> anonymizer.anonymize(input) + " " + orderingScheme.ordering(input));
return PlanPrinter.formatOrderingScheme(anonymizer, orderingScheme);
}

@SafeVarargs
Expand Down Expand Up @@ -2177,6 +2177,11 @@ public NodeRepresentation addNode(
}
}

private static String formatOrderingScheme(Anonymizer anonymizer, OrderingScheme orderingScheme)
{
return formatCollection(orderingScheme.orderBy(), input -> anonymizer.anonymize(input) + " " + orderingScheme.ordering(input));
}

private static <T> String formatCollection(Collection<T> collection, Function<T, String> formatter)
{
return collection.stream()
Expand All @@ -2201,9 +2206,9 @@ public static String formatAggregation(Anonymizer anonymizer, Aggregation aggreg
builder.append(formatFunctionName(aggregation.getResolvedFunction()))
.append('(').append(arguments);

aggregation.getOrderingScheme().ifPresent(orderingScheme -> builder.append(' ').append(orderingScheme.orderBy().stream()
.map(input -> anonymizer.anonymize(input) + " " + orderingScheme.ordering(input))
.collect(joining(", "))));
aggregation.getOrderingScheme()
.map(orderingScheme -> formatOrderingScheme(anonymizer, orderingScheme))
.ifPresent(ordering -> builder.append(' ').append(ordering));

builder.append(')');

Expand Down

0 comments on commit 9949d82

Please sign in to comment.