Search in sources :

Example 1 with MaterializationInfo

use of io.confluent.ksql.execution.materialization.MaterializationInfo in project ksql by confluentinc.

the class StreamAggregateBuilderTest method assertCorrectMaterializationBuilder.

private void assertCorrectMaterializationBuilder(final KTableHolder<?> result, final boolean windowed) {
    assertThat(result.getMaterializationBuilder().isPresent(), is(true));
    final MaterializationInfo info = result.getMaterializationBuilder().get().build();
    assertThat(info.stateStoreName(), equalTo("agg-regate-Materialize"));
    assertThat(info.getSchema(), equalTo(OUTPUT_SCHEMA));
    assertThat(info.getStateStoreSchema(), equalTo(AGGREGATE_SCHEMA));
    assertThat(info.getTransforms(), hasSize(1 + (windowed ? 1 : 0)));
    final MapperInfo aggMapInfo = (MapperInfo) info.getTransforms().get(0);
    final KsqlTransformer<Object, GenericRow> mapper = aggMapInfo.getMapper(name -> null);
    // Given:
    final GenericKey key = mock(GenericKey.class);
    final GenericRow value = mock(GenericRow.class);
    // When:
    mapper.transform(key, value, ctx);
    // Then:
    verify(resultMapper).transform(key, value, ctx);
}
Also used : GenericRow(io.confluent.ksql.GenericRow) MaterializationInfo(io.confluent.ksql.execution.materialization.MaterializationInfo) MapperInfo(io.confluent.ksql.execution.materialization.MaterializationInfo.MapperInfo) GenericKey(io.confluent.ksql.GenericKey)

Example 2 with MaterializationInfo

use of io.confluent.ksql.execution.materialization.MaterializationInfo in project ksql by confluentinc.

the class TableAggregateBuilderTest method shouldBuildMaterializationCorrectlyForAggregate.

@Test
public void shouldBuildMaterializationCorrectlyForAggregate() {
    // When:
    final KTableHolder<?> result = aggregate.build(planBuilder, planInfo);
    // Then:
    assertThat(result.getMaterializationBuilder().isPresent(), is(true));
    final MaterializationInfo info = result.getMaterializationBuilder().get().build();
    assertThat(info.stateStoreName(), equalTo("agg-regate-Materialize"));
    assertThat(info.getSchema(), equalTo(AGGREGATE_SCHEMA));
    assertThat(info.getStateStoreSchema(), equalTo(AGGREGATE_SCHEMA));
    assertThat(info.getTransforms(), hasSize(1));
    final MapperInfo aggMapInfo = (MapperInfo) info.getTransforms().get(0);
    final KsqlTransformer<Object, GenericRow> mapper = aggMapInfo.getMapper(name -> null);
    // Given:
    final GenericKey key = mock(GenericKey.class);
    final GenericRow value = mock(GenericRow.class);
    // When:
    mapper.transform(key, value, ctx);
    // Then:
    verify(resultMapper).transform(key, value, ctx);
}
Also used : GenericRow(io.confluent.ksql.GenericRow) MaterializationInfo(io.confluent.ksql.execution.materialization.MaterializationInfo) MapperInfo(io.confluent.ksql.execution.materialization.MaterializationInfo.MapperInfo) GenericKey(io.confluent.ksql.GenericKey) Test(org.junit.Test)

Aggregations

GenericKey (io.confluent.ksql.GenericKey)2 GenericRow (io.confluent.ksql.GenericRow)2 MaterializationInfo (io.confluent.ksql.execution.materialization.MaterializationInfo)2 MapperInfo (io.confluent.ksql.execution.materialization.MaterializationInfo.MapperInfo)2 Test (org.junit.Test)1