use of io.prestosql.spi.plan.OrderingScheme in project hetu-core by openlookeng.
the class SymbolMapper method map.
private OrderingScheme map(OrderingScheme orderingScheme) {
ImmutableList.Builder<Symbol> symbols = ImmutableList.builder();
ImmutableMap.Builder<Symbol, SortOrder> orderings = ImmutableMap.builder();
Set<Symbol> seenCanonicals = new HashSet<>(orderingScheme.getOrderBy().size());
for (Symbol symbol : orderingScheme.getOrderBy()) {
Symbol canonical = map(symbol);
if (seenCanonicals.add(canonical)) {
symbols.add(canonical);
orderings.put(canonical, orderingScheme.getOrdering(symbol));
}
}
return new OrderingScheme(symbols.build(), orderings.build());
}
use of io.prestosql.spi.plan.OrderingScheme in project hetu-core by openlookeng.
the class PlanPrinter method formatAggregation.
public static String formatAggregation(Aggregation aggregation) {
StringBuilder builder = new StringBuilder();
String arguments = Joiner.on(", ").join(aggregation.getArguments());
if (aggregation.getArguments().isEmpty() && "count".equalsIgnoreCase(aggregation.getFunctionCall().getDisplayName())) {
arguments = "*";
}
if (aggregation.isDistinct()) {
arguments = "DISTINCT " + arguments;
}
builder.append(aggregation.getFunctionCall().getDisplayName()).append('(').append(arguments);
aggregation.getOrderingScheme().ifPresent(orderingScheme -> builder.append(' ').append(orderingScheme.getOrderBy().stream().map(input -> input + " " + orderingScheme.getOrdering(input)).collect(joining(", "))));
builder.append(')');
aggregation.getFilter().ifPresent(expression -> builder.append(" FILTER (WHERE ").append(expression).append(")"));
aggregation.getMask().ifPresent(symbol -> builder.append(" (mask = ").append(symbol).append(")"));
return builder.toString();
}
use of io.prestosql.spi.plan.OrderingScheme in project hetu-core by openlookeng.
the class TestEffectivePredicateExtractor method testSort.
@Test
public void testSort() {
PlanNode node = new SortNode(newId(), filter(baseTableScan, and(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))), new OrderingScheme(ImmutableList.of(A), ImmutableMap.of(A, SortOrder.ASC_NULLS_LAST)), false);
Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10))));
}
Aggregations