use of io.confluent.ksql.execution.plan.KGroupedStreamHolder in project ksql by confluentinc.
the class StreamGroupByBuilderV1Test method shouldPerformGroupByCorrectly.
@Test
public void shouldPerformGroupByCorrectly() {
// When:
final KGroupedStreamHolder result = buildGroupBy(builder, streamHolder, groupBy);
// Then:
assertThat(result.getGroupedStream(), is(groupedStream));
verify(sourceStream).filter(any());
verify(filteredStream).groupBy(any(), same(grouped));
verifyNoMoreInteractions(filteredStream, sourceStream);
}
use of io.confluent.ksql.execution.plan.KGroupedStreamHolder in project ksql by confluentinc.
the class StreamGroupByBuilderV1Test method shouldPerformGroupByKeyCorrectly.
@Test
public void shouldPerformGroupByKeyCorrectly() {
// When:
final KGroupedStreamHolder result = builder.build(streamHolder, groupByKey);
// Then:
assertThat(result.getGroupedStream(), is(groupedStream));
verify(sourceStream).groupByKey(grouped);
verifyNoMoreInteractions(sourceStream);
}
use of io.confluent.ksql.execution.plan.KGroupedStreamHolder in project ksql by confluentinc.
the class StreamGroupByBuilderV1Test method shouldReturnCorrectSchemaForGroupBy.
@Test
public void shouldReturnCorrectSchemaForGroupBy() {
// When:
final KGroupedStreamHolder result = buildGroupBy(builder, streamHolder, groupBy);
// Then:
assertThat(result.getSchema(), is(REKEYED_SCHEMA));
}
use of io.confluent.ksql.execution.plan.KGroupedStreamHolder in project ksql by confluentinc.
the class StreamGroupByBuilderBase method build.
public <K> KGroupedStreamHolder build(final KStreamHolder<K> stream, final QueryContext queryContext, final Formats formats, final List<Expression> groupByExpressions) {
final LogicalSchema sourceSchema = stream.getSchema();
final List<CompiledExpression> groupBy = CodeGenRunner.compileExpressions(groupByExpressions.stream(), "Group By", sourceSchema, buildContext.getKsqlConfig(), buildContext.getFunctionRegistry());
final ProcessingLogger logger = buildContext.getProcessingLogger(queryContext);
final GroupByParams params = paramsFactory.build(sourceSchema, groupBy, logger);
final Grouped<GenericKey, GenericRow> grouped = buildGrouped(formats, params.getSchema(), queryContext, buildContext, groupedFactory);
final KGroupedStream<GenericKey, GenericRow> groupedStream = stream.getStream().filter((k, v) -> v != null).groupBy((k, v) -> params.getMapper().apply(v), grouped);
return KGroupedStreamHolder.of(groupedStream, params.getSchema());
}
Aggregations