From 356835a04595330a547036adaf66a31c7c771b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Osipiuk?= Date: Wed, 30 Oct 2024 18:03:34 +0100 Subject: [PATCH] Reuse formatOrderingScheme method --- .../trino/sql/planner/planprinter/PlanPrinter.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/PlanPrinter.java b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/PlanPrinter.java index 321244aeefb7f..51cc2d18207bd 100644 --- a/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/PlanPrinter.java +++ b/core/trino-main/src/main/java/io/trino/sql/planner/planprinter/PlanPrinter.java @@ -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 @@ -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 String formatCollection(Collection collection, Function formatter) { return collection.stream() @@ -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(')');