use of io.confluent.ksql.execution.plan.KGroupedTableHolder in project ksql by confluentinc.
the class TableGroupByBuilderBase method build.
public <K> KGroupedTableHolder build(final KTableHolder<K> table, final QueryContext queryContext, final Formats formats, final List<Expression> groupByExpressions) {
final LogicalSchema sourceSchema = table.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 PhysicalSchema physicalSchema = PhysicalSchema.from(params.getSchema(), formats.getKeyFeatures(), formats.getValueFeatures());
final Serde<GenericKey> keySerde = buildContext.buildKeySerde(formats.getKeyFormat(), physicalSchema, queryContext);
final Serde<GenericRow> valSerde = buildContext.buildValueSerde(formats.getValueFormat(), physicalSchema, queryContext);
final Grouped<GenericKey, GenericRow> grouped = groupedFactory.create(StreamsUtil.buildOpName(queryContext), keySerde, valSerde);
final KGroupedTable<GenericKey, GenericRow> groupedTable = table.getTable().filter((k, v) -> v != null).groupBy(new TableKeyValueMapper<>(params.getMapper()), grouped);
return KGroupedTableHolder.of(groupedTable, params.getSchema());
}
use of io.confluent.ksql.execution.plan.KGroupedTableHolder in project ksql by confluentinc.
the class TableGroupByBuilderV1Test method shouldPerformGroupByCorrectly.
@Test
public void shouldPerformGroupByCorrectly() {
// When:
final KGroupedTableHolder result = build(builder, tableHolder, groupBy);
// Then:
assertThat(result.getGroupedTable(), is(groupedTable));
verify(sourceTable).filter(any());
verify(filteredTable).groupBy(any(), same(grouped));
verifyNoMoreInteractions(filteredTable, sourceTable);
}
use of io.confluent.ksql.execution.plan.KGroupedTableHolder in project ksql by confluentinc.
the class TableGroupByBuilderV1Test method shouldReturnCorrectSchema.
@Test
public void shouldReturnCorrectSchema() {
// When:
final KGroupedTableHolder result = build(builder, tableHolder, groupBy);
// Then:
assertThat(result.getSchema(), is(REKEYED_SCHEMA));
}
use of io.confluent.ksql.execution.plan.KGroupedTableHolder in project ksql by confluentinc.
the class TableGroupByBuilderTest method shouldReturnCorrectSchema.
@Test
public void shouldReturnCorrectSchema() {
// When:
final KGroupedTableHolder result = build(builder, tableHolder, groupBy);
// Then:
assertThat(result.getSchema(), is(REKEYED_SCHEMA));
}
use of io.confluent.ksql.execution.plan.KGroupedTableHolder in project ksql by confluentinc.
the class TableGroupByBuilderTest method shouldPerformGroupByCorrectly.
@Test
public void shouldPerformGroupByCorrectly() {
// When:
final KGroupedTableHolder result = build(builder, tableHolder, groupBy);
// Then:
assertThat(result.getGroupedTable(), is(groupedTable));
verify(sourceTable).filter(any());
verify(filteredTable).groupBy(any(), same(grouped));
verifyNoMoreInteractions(filteredTable, sourceTable);
}
Aggregations