use of org.apache.pinot.core.query.reduce.PostAggregationHandler in project trino by trinodb.
the class DynamicTableBuilder method getAggregateTypes.
private static Map<String, PinotColumnNameAndTrinoType> getAggregateTypes(SchemaTableName schemaTableName, QueryContext queryContext, Map<String, ColumnHandle> columnHandles) {
// A mapping from pinot expression to the returned pinot column name and trino type
// Note: the column name is set by the PostAggregationHandler
List<ExpressionContext> aggregateColumnExpressions = queryContext.getSelectExpressions().stream().filter(DynamicTableBuilder::hasAggregate).collect(toImmutableList());
queryContext = new QueryContext.Builder().setAliasList(queryContext.getAliasList()).setSelectExpressions(aggregateColumnExpressions).build();
DataSchema preAggregationSchema = getPreAggregationDataSchema(queryContext);
PostAggregationHandler postAggregationHandler = new PostAggregationHandler(queryContext, preAggregationSchema);
DataSchema postAggregtionSchema = postAggregationHandler.getResultDataSchema();
ImmutableMap.Builder<String, PinotColumnNameAndTrinoType> aggregationTypesBuilder = ImmutableMap.builder();
for (int index = 0; index < postAggregtionSchema.size(); index++) {
aggregationTypesBuilder.put(// Quoting of identifiers is not done to match the corresponding column name in the ResultTable returned from Pinot. Quoting will be done by `DynamicTablePqlExtractor`.
rewriteExpression(schemaTableName, aggregateColumnExpressions.get(index), columnHandles).toString(), new PinotColumnNameAndTrinoType(postAggregtionSchema.getColumnName(index), toTrinoType(postAggregtionSchema.getColumnDataType(index))));
}
return aggregationTypesBuilder.buildOrThrow();
}
Aggregations