Search in sources :

Example 1 with KsqlWindowExpression

use of io.confluent.ksql.parser.tree.KsqlWindowExpression in project ksql by confluentinc.

the class SchemaKGroupedStream method aggregate.

@SuppressWarnings("unchecked")
public SchemaKTable aggregate(final Initializer initializer, final UdafAggregator aggregator, final WindowExpression windowExpression, final Serde<GenericRow> topicValueSerDe) {
    final KTable aggKtable;
    if (windowExpression != null) {
        final Materialized<String, GenericRow, ?> materialized = Materialized.<String, GenericRow, WindowStore<Bytes, byte[]>>with(Serdes.String(), topicValueSerDe);
        final KsqlWindowExpression ksqlWindowExpression = windowExpression.getKsqlWindowExpression();
        aggKtable = ksqlWindowExpression.applyAggregate(kgroupedStream, initializer, aggregator, materialized);
    } else {
        aggKtable = kgroupedStream.aggregate(initializer, aggregator, Materialized.with(Serdes.String(), topicValueSerDe));
    }
    return new SchemaKTable(schema, aggKtable, keyField, sourceSchemaKStreams, windowExpression != null, SchemaKStream.Type.AGGREGATE, functionRegistry, schemaRegistryClient);
}
Also used : GenericRow(io.confluent.ksql.GenericRow) WindowStore(org.apache.kafka.streams.state.WindowStore) KsqlWindowExpression(io.confluent.ksql.parser.tree.KsqlWindowExpression) KTable(org.apache.kafka.streams.kstream.KTable)

Aggregations

GenericRow (io.confluent.ksql.GenericRow)1 KsqlWindowExpression (io.confluent.ksql.parser.tree.KsqlWindowExpression)1 KTable (org.apache.kafka.streams.kstream.KTable)1 WindowStore (org.apache.kafka.streams.state.WindowStore)1