use of io.trino.plugin.pinot.query.AggregateExpression in project trino by trinodb.
the class PinotMetadata method resolveAggregateExpressionWithAlias.
private static PinotColumnHandle resolveAggregateExpressionWithAlias(PinotColumnHandle aggregateColumn, Map<String, PinotColumnHandle> projectionsMap) {
checkState(aggregateColumn.isAggregate() && aggregateColumn.getPushedDownAggregateFunctionName().isPresent() && aggregateColumn.getPushedDownAggregateFunctionArgument().isPresent(), "Column is not a pushed down aggregate column");
PinotColumnHandle selection = projectionsMap.get(aggregateColumn.getPushedDownAggregateFunctionArgument().get());
if (selection != null && selection.isAliased()) {
AggregateExpression pushedDownAggregateExpression = new AggregateExpression(aggregateColumn.getPushedDownAggregateFunctionName().get(), aggregateColumn.getPushedDownAggregateFunctionArgument().get(), aggregateColumn.isReturnNullOnEmptyGroup());
AggregateExpression newPushedDownAggregateExpression = replaceIdentifier(pushedDownAggregateExpression, selection);
return new PinotColumnHandle(pushedDownAggregateExpression.toFieldName(), aggregateColumn.getDataType(), newPushedDownAggregateExpression.toExpression(), true, aggregateColumn.isAggregate(), aggregateColumn.isReturnNullOnEmptyGroup(), aggregateColumn.getPushedDownAggregateFunctionName(), Optional.of(newPushedDownAggregateExpression.getArgument()));
}
return aggregateColumn;
}
use of io.trino.plugin.pinot.query.AggregateExpression in project trino by trinodb.
the class ImplementAvg method rewrite.
@Override
public Optional<AggregateExpression> rewrite(AggregateFunction aggregateFunction, Captures captures, RewriteContext<Void> context) {
Variable argument = captures.get(ARGUMENT);
PinotColumnHandle columnHandle = (PinotColumnHandle) context.getAssignment(argument.getName());
return Optional.of(new AggregateExpression(aggregateFunction.getFunctionName(), identifierQuote.apply(columnHandle.getColumnName()), true));
}
use of io.trino.plugin.pinot.query.AggregateExpression in project trino by trinodb.
the class ImplementCountDistinct method rewrite.
@Override
public Optional<AggregateExpression> rewrite(AggregateFunction aggregateFunction, Captures captures, RewriteContext<Void> context) {
if (!isCountDistinctPushdownEnabled(context.getSession())) {
return Optional.empty();
}
Variable argument = captures.get(ARGUMENT);
verify(aggregateFunction.getOutputType() == BIGINT);
return Optional.of(new AggregateExpression("distinctcount", identifierQuote.apply(argument.getName()), false));
}
use of io.trino.plugin.pinot.query.AggregateExpression in project trino by trinodb.
the class ImplementMinMax method rewrite.
@Override
public Optional<AggregateExpression> rewrite(AggregateFunction aggregateFunction, Captures captures, RewriteContext<Void> context) {
Variable argument = captures.get(ARGUMENT);
PinotColumnHandle columnHandle = (PinotColumnHandle) context.getAssignment(argument.getName());
verify(columnHandle.getDataType().equals(aggregateFunction.getOutputType()));
return Optional.of(new AggregateExpression(aggregateFunction.getFunctionName(), identifierQuote.apply(columnHandle.getColumnName()), true));
}
use of io.trino.plugin.pinot.query.AggregateExpression in project trino by trinodb.
the class ImplementApproxDistinct method rewrite.
@Override
public Optional<AggregateExpression> rewrite(AggregateFunction aggregateFunction, Captures captures, RewriteContext<Void> context) {
Variable argument = captures.get(ARGUMENT);
PinotColumnHandle columnHandle = (PinotColumnHandle) context.getAssignment(argument.getName());
return Optional.of(new AggregateExpression("distinctcounthll", identifierQuote.apply(columnHandle.getColumnName()), false));
}
Aggregations