use of io.confluent.ksql.execution.windows.KsqlWindowExpression in project ksql by confluentinc.
the class ExpressionParserTest method shouldParseWindowExpression.
@Test
public void shouldParseWindowExpression() {
// When:
final KsqlWindowExpression parsed = ExpressionParser.parseWindowExpression("TUMBLING (SIZE 1 DAYS)");
// Then:
assertThat(parsed, equalTo(new TumblingWindowExpression(parsed.getLocation(), new WindowTimeClause(1, TimeUnit.DAYS), Optional.empty(), Optional.empty())));
}
use of io.confluent.ksql.execution.windows.KsqlWindowExpression in project ksql by confluentinc.
the class StreamAggregateBuilder method build.
@SuppressWarnings({ "rawtypes", "unchecked" })
static KTableHolder<Windowed<GenericKey>> build(final KGroupedStreamHolder groupedStream, final StreamWindowedAggregate aggregate, final RuntimeBuildContext buildContext, final MaterializedFactory materializedFactory, final AggregateParamsFactory aggregateParamsFactory) {
final LogicalSchema sourceSchema = groupedStream.getSchema();
final List<ColumnName> nonFuncColumns = aggregate.getNonAggregateColumns();
final AggregateParams aggregateParams = aggregateParamsFactory.create(sourceSchema, nonFuncColumns, buildContext.getFunctionRegistry(), aggregate.getAggregationFunctions(), true, buildContext.getKsqlConfig());
final LogicalSchema aggregateSchema = aggregateParams.getAggregateSchema();
final LogicalSchema resultSchema = aggregateParams.getSchema();
final KsqlWindowExpression ksqlWindowExpression = aggregate.getWindowExpression();
final KTable<Windowed<GenericKey>, GenericRow> aggregated = ksqlWindowExpression.accept(new WindowedAggregator(groupedStream.getGroupedStream(), aggregate, aggregateSchema, buildContext, materializedFactory, aggregateParams), null);
final KudafAggregator<Windowed<GenericKey>> aggregator = aggregateParams.getAggregator();
KTable<Windowed<GenericKey>, GenericRow> reduced = aggregated.transformValues(() -> new KsTransformer<>(aggregator.getResultMapper()), Named.as(StreamsUtil.buildOpName(AggregateBuilderUtils.outputContext(aggregate))));
final MaterializationInfo.Builder materializationBuilder = AggregateBuilderUtils.materializationInfoBuilder(aggregateParams.getAggregator(), aggregate, aggregateSchema, resultSchema);
reduced = reduced.transformValues(() -> new KsTransformer<>(new WindowBoundsPopulator()), Named.as(StreamsUtil.buildOpName(AggregateBuilderUtils.windowSelectContext(aggregate))));
materializationBuilder.map(pl -> (KsqlTransformer) new WindowBoundsPopulator(), resultSchema, AggregateBuilderUtils.windowSelectContext(aggregate));
return KTableHolder.materialized(reduced, resultSchema, ExecutionKeyFactory.windowed(buildContext, ksqlWindowExpression.getWindowInfo()), materializationBuilder);
}
Aggregations