Search in sources :

Example 1 with JoinType

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

the class SchemaKStreamTest method shouldBuildStepForStreamStreamJoin.

@Test
// can be fixed after GRACE clause is made mandatory
@SuppressWarnings({ "rawtypes", "deprecation" })
public void shouldBuildStepForStreamStreamJoin() {
    // Given:
    final SchemaKStream initialSchemaKStream = buildSchemaKStreamForJoin(ksqlStream);
    final List<Pair<JoinType, StreamStreamJoin>> cases = ImmutableList.of(Pair.of(JoinType.OUTER, initialSchemaKStream::outerJoin), Pair.of(JoinType.LEFT, initialSchemaKStream::leftJoin), Pair.of(JoinType.INNER, initialSchemaKStream::innerJoin));
    final JoinWindows joinWindows = JoinWindows.of(Duration.ofSeconds(1));
    final WindowTimeClause grace = new WindowTimeClause(5, TimeUnit.SECONDS);
    final WithinExpression withinExpression = new WithinExpression(1, TimeUnit.SECONDS, grace);
    for (final Pair<JoinType, StreamStreamJoin> testcase : cases) {
        final SchemaKStream joinedKStream = testcase.right.join(schemaKStream, KEY, withinExpression, valueFormat.getFormatInfo(), valueFormat.getFormatInfo(), childContextStacker);
        // Then:
        assertThat(joinedKStream.getSourceStep(), equalTo(ExecutionStepFactory.streamStreamJoin(childContextStacker, testcase.left, KEY, InternalFormats.of(keyFormat, valueFormat.getFormatInfo()), InternalFormats.of(keyFormat, valueFormat.getFormatInfo()), initialSchemaKStream.getSourceStep(), schemaKStream.getSourceStep(), joinWindows, Optional.of(grace))));
    }
}
Also used : JoinWindows(org.apache.kafka.streams.kstream.JoinWindows) WithinExpression(io.confluent.ksql.parser.tree.WithinExpression) JoinType(io.confluent.ksql.execution.plan.JoinType) WindowTimeClause(io.confluent.ksql.execution.windows.WindowTimeClause) Pair(io.confluent.ksql.util.Pair) Test(org.junit.Test)

Aggregations

JoinType (io.confluent.ksql.execution.plan.JoinType)1 WindowTimeClause (io.confluent.ksql.execution.windows.WindowTimeClause)1 WithinExpression (io.confluent.ksql.parser.tree.WithinExpression)1 Pair (io.confluent.ksql.util.Pair)1 JoinWindows (org.apache.kafka.streams.kstream.JoinWindows)1 Test (org.junit.Test)1