Search in sources :

Example 1 with PlanInfo

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

the class SourceBuilderV1Test method shouldApplyCorrectTransformationsToSourceTableWithDownstreamRepartition.

@Test
@SuppressWarnings("unchecked")
public void shouldApplyCorrectTransformationsToSourceTableWithDownstreamRepartition() {
    // Given:
    givenUnwindowedSourceTableV1(true, LEGACY_PSEUDOCOLUMN_VERSION_NUMBER);
    final PlanInfo planInfo = givenDownstreamRepartition(tableSourceV1);
    // When:
    final KTableHolder<GenericKey> builtKTable = tableSourceV1.build(planBuilder, planInfo);
    // Then:
    assertThat(builtKTable.getTable(), is(kTable));
    final InOrder validator = inOrder(streamsBuilder, kTable);
    validator.verify(streamsBuilder).table(eq(TOPIC_NAME), eq(consumed));
    validator.verify(kTable).transformValues(any(ValueTransformerWithKeySupplier.class));
    verify(consumedFactory).create(keySerde, valueSerde);
    verify(consumed).withTimestampExtractor(any());
    verify(consumed).withOffsetResetPolicy(AutoOffsetReset.EARLIEST);
    verify(kTable, never()).mapValues(any(ValueMapper.class), any(Materialized.class));
}
Also used : PlanInfo(io.confluent.ksql.execution.plan.PlanInfo) InOrder(org.mockito.InOrder) ValueMapper(org.apache.kafka.streams.kstream.ValueMapper) GenericKey(io.confluent.ksql.GenericKey) Materialized(org.apache.kafka.streams.kstream.Materialized) ValueTransformerWithKeySupplier(org.apache.kafka.streams.kstream.ValueTransformerWithKeySupplier) Test(org.junit.Test)

Example 2 with PlanInfo

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

the class PlanInfoExtractorTest method shouldExtractMultipleSources.

@Test
public void shouldExtractMultipleSources() {
    // When:
    final PlanInfo planInfo = streamAndTableJoined.extractPlanInfo(planInfoExtractor);
    // Then:
    assertThat(planInfo.isRepartitionedInPlan(streamSource), is(false));
    assertThat(planInfo.isRepartitionedInPlan(tableSource), is(false));
}
Also used : PlanInfo(io.confluent.ksql.execution.plan.PlanInfo) Test(org.junit.Test)

Example 3 with PlanInfo

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

the class PlanInfoExtractorTest method shouldExtractRepartitionBeforeJoin.

@Test
public void shouldExtractRepartitionBeforeJoin() {
    // When:
    final PlanInfo planInfo = streamRepartitionedAndTableJoined.extractPlanInfo(planInfoExtractor);
    // Then:
    assertThat(planInfo.isRepartitionedInPlan(streamSource), is(true));
    assertThat(planInfo.isRepartitionedInPlan(tableSource), is(false));
}
Also used : PlanInfo(io.confluent.ksql.execution.plan.PlanInfo) Test(org.junit.Test)

Example 4 with PlanInfo

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

the class PlanInfoExtractorTest method shouldExtractRepartitionAfterJoin.

@Test
public void shouldExtractRepartitionAfterJoin() {
    // When:
    final PlanInfo planInfo = streamAndTableJoinedRepartitioned.extractPlanInfo(planInfoExtractor);
    // Then:
    assertThat(planInfo.isRepartitionedInPlan(streamSource), is(false));
    assertThat(planInfo.isRepartitionedInPlan(tableSource), is(false));
}
Also used : PlanInfo(io.confluent.ksql.execution.plan.PlanInfo) Test(org.junit.Test)

Example 5 with PlanInfo

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

the class SourceBuilderTest method givenDownstreamRepartition.

private static PlanInfo givenDownstreamRepartition(final ExecutionStep<?> sourceStep) {
    final PlanInfo mockPlanInfo = mock(PlanInfo.class);
    when(mockPlanInfo.isRepartitionedInPlan(sourceStep)).thenReturn(true);
    return mockPlanInfo;
}
Also used : PlanInfo(io.confluent.ksql.execution.plan.PlanInfo)

Aggregations

PlanInfo (io.confluent.ksql.execution.plan.PlanInfo)11 Test (org.junit.Test)7 GenericKey (io.confluent.ksql.GenericKey)3 Materialized (org.apache.kafka.streams.kstream.Materialized)3 KsqlException (io.confluent.ksql.util.KsqlException)2 GenericRow (io.confluent.ksql.GenericRow)1 MaterializationInfo (io.confluent.ksql.execution.materialization.MaterializationInfo)1 ExecutionKeyFactory (io.confluent.ksql.execution.plan.ExecutionKeyFactory)1 KStreamHolder (io.confluent.ksql.execution.plan.KStreamHolder)1 KTableHolder (io.confluent.ksql.execution.plan.KTableHolder)1 PlanInfoExtractor (io.confluent.ksql.execution.plan.PlanInfoExtractor)1 SourceStep (io.confluent.ksql.execution.plan.SourceStep)1 StreamSource (io.confluent.ksql.execution.plan.StreamSource)1 TableSourceV1 (io.confluent.ksql.execution.plan.TableSourceV1)1 WindowedStreamSource (io.confluent.ksql.execution.plan.WindowedStreamSource)1 WindowedTableSource (io.confluent.ksql.execution.plan.WindowedTableSource)1 RuntimeBuildContext (io.confluent.ksql.execution.runtime.RuntimeBuildContext)1 AddKeyAndPseudoColumns (io.confluent.ksql.execution.streams.SourceBuilderUtils.AddKeyAndPseudoColumns)1 SourceBuilderUtils.buildSchema (io.confluent.ksql.execution.streams.SourceBuilderUtils.buildSchema)1 SourceBuilderUtils.buildSourceConsumed (io.confluent.ksql.execution.streams.SourceBuilderUtils.buildSourceConsumed)1