use of io.confluent.ksql.schema.ksql.ColumnAliasGenerator in project ksql by confluentinc.
the class GroupByParamsFactory method expressionSchema.
private static LogicalSchema expressionSchema(final LogicalSchema sourceSchema, final List<CompiledExpression> groupBys) {
final ColumnAliasGenerator columnAliasGenerator = ColumnNames.columnAliasGenerator(Stream.of(sourceSchema));
final LogicalSchema.Builder schemaBuilder = LogicalSchema.builder();
for (final CompiledExpression groupBy : groupBys) {
final Expression groupByExp = groupBy.getExpression();
final ColumnName columnName = groupByExp instanceof ColumnReferenceExp ? ((ColumnReferenceExp) groupByExp).getColumnName() : columnAliasGenerator.uniqueAliasFor(groupByExp);
schemaBuilder.keyColumn(columnName, groupBy.getExpressionType());
}
schemaBuilder.valueColumns(sourceSchema.value());
return schemaBuilder.build();
}
Aggregations