Search in sources :

Example 1 with WindowedTableSource

use of io.confluent.ksql.execution.plan.WindowedTableSource in project ksql by confluentinc.

the class SourceBuilderV1Test method givenWindowedSourceTable.

private void givenWindowedSourceTable(final int pseudoColumnVersion) {
    when(buildContext.buildKeySerde(any(), any(), any(), any())).thenReturn(windowedKeySerde);
    givenConsumed(consumedWindowed, windowedKeySerde);
    givenConsumed(consumedWindowed, windowedKeySerde);
    windowedTableSource = new WindowedTableSource(new ExecutionStepPropertiesV1(ctx), TOPIC_NAME, Formats.of(keyFormatInfo, valueFormatInfo, KEY_FEATURES, VALUE_FEATURES), windowInfo, TIMESTAMP_COLUMN, SOURCE_SCHEMA, OptionalInt.of(pseudoColumnVersion));
}
Also used : ExecutionStepPropertiesV1(io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1) WindowedTableSource(io.confluent.ksql.execution.plan.WindowedTableSource)

Example 2 with WindowedTableSource

use of io.confluent.ksql.execution.plan.WindowedTableSource in project ksql by confluentinc.

the class SourceBuilderV1 method buildWindowedTable.

KTableHolder<Windowed<GenericKey>> buildWindowedTable(final RuntimeBuildContext buildContext, final SourceStep<KTableHolder<Windowed<GenericKey>>> source, final ConsumedFactory consumedFactory, final MaterializedFactory materializedFactory, final PlanInfo planInfo) {
    final PhysicalSchema physicalSchema = getPhysicalSchema(source);
    final Serde<GenericRow> valueSerde = getValueSerde(buildContext, source, physicalSchema);
    final WindowInfo windowInfo;
    if (source instanceof WindowedTableSource) {
        windowInfo = ((WindowedTableSource) source).getWindowInfo();
    } else {
        throw new IllegalArgumentException("Expected a version of WindowedTableSource");
    }
    final Serde<Windowed<GenericKey>> keySerde = SourceBuilderUtils.getWindowedKeySerde(source, physicalSchema, buildContext, windowInfo);
    final Consumed<Windowed<GenericKey>, GenericRow> consumed = buildSourceConsumed(source, keySerde, valueSerde, AutoOffsetReset.EARLIEST, buildContext, consumedFactory);
    final String stateStoreName = tableChangeLogOpName(source.getProperties());
    final Materialized<Windowed<GenericKey>, GenericRow, KeyValueStore<Bytes, byte[]>> materialized = materializedFactory.create(keySerde, valueSerde, stateStoreName);
    final KTable<Windowed<GenericKey>, GenericRow> ktable = buildKTable(source, buildContext, consumed, windowedKeyGenerator(source.getSourceSchema()), materialized, valueSerde, stateStoreName, planInfo);
    return KTableHolder.materialized(ktable, buildSchema(source, true), ExecutionKeyFactory.windowed(buildContext, windowInfo), MaterializationInfo.builder(stateStoreName, physicalSchema.logicalSchema()));
}
Also used : KeyValueStore(org.apache.kafka.streams.state.KeyValueStore) WindowInfo(io.confluent.ksql.serde.WindowInfo) GenericRow(io.confluent.ksql.GenericRow) Windowed(org.apache.kafka.streams.kstream.Windowed) PhysicalSchema(io.confluent.ksql.schema.ksql.PhysicalSchema) SourceBuilderUtils.getPhysicalSchema(io.confluent.ksql.execution.streams.SourceBuilderUtils.getPhysicalSchema) WindowedTableSource(io.confluent.ksql.execution.plan.WindowedTableSource)

Example 3 with WindowedTableSource

use of io.confluent.ksql.execution.plan.WindowedTableSource in project ksql by confluentinc.

the class StepSchemaResolverTest method shouldResolveSchemaForWindowedTableSource.

@Test
public void shouldResolveSchemaForWindowedTableSource() {
    // Given:
    final WindowedTableSource step = new WindowedTableSource(PROPERTIES, "foo", formats, mock(WindowInfo.class), Optional.empty(), SCHEMA, OptionalInt.of(SystemColumns.CURRENT_PSEUDOCOLUMN_VERSION_NUMBER));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(SCHEMA.withPseudoAndKeyColsInValue(true)));
}
Also used : LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) WindowedTableSource(io.confluent.ksql.execution.plan.WindowedTableSource) WindowInfo(io.confluent.ksql.serde.WindowInfo) Test(org.junit.Test)

Aggregations

WindowedTableSource (io.confluent.ksql.execution.plan.WindowedTableSource)3 WindowInfo (io.confluent.ksql.serde.WindowInfo)2 GenericRow (io.confluent.ksql.GenericRow)1 ExecutionStepPropertiesV1 (io.confluent.ksql.execution.plan.ExecutionStepPropertiesV1)1 SourceBuilderUtils.getPhysicalSchema (io.confluent.ksql.execution.streams.SourceBuilderUtils.getPhysicalSchema)1 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)1 PhysicalSchema (io.confluent.ksql.schema.ksql.PhysicalSchema)1 Windowed (org.apache.kafka.streams.kstream.Windowed)1 KeyValueStore (org.apache.kafka.streams.state.KeyValueStore)1 Test (org.junit.Test)1