use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class ForeignKeyTableTableJoinBuilderTest method shouldDoInnerJoinOnNonKey.
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void shouldDoInnerJoinOnNonKey() {
// Given:
givenInnerJoin(left, JOIN_COLUMN);
// When:
final KTableHolder<Struct> result = join.build(planBuilder, planInfo);
// Then:
final ArgumentCaptor<KsqlKeyExtractor> ksqlKeyExtractor = ArgumentCaptor.forClass(KsqlKeyExtractor.class);
verify(leftKTable).join(same(rightKTable), ksqlKeyExtractor.capture(), eq(new KsqlValueJoiner(LEFT_SCHEMA.value().size(), RIGHT_SCHEMA.value().size(), 0)), any(Materialized.class));
verifyNoMoreInteractions(leftKTable, rightKTable, resultKTable);
final GenericKey extractedKey = GenericKey.genericKey(FOREIGN_KEY);
assertThat(ksqlKeyExtractor.getValue().apply(LEFT_ROW), is(extractedKey));
assertThat(result.getTable(), is(resultKTable));
assertThat(result.getExecutionKeyFactory(), is(executionKeyFactory));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class KsMaterializedTableIQv2Test method getIteratorResult.
private static StateQueryResult getIteratorResult() {
final StateQueryResult result = new StateQueryResult<>();
Set<GenericKey> keySet = new HashSet<>();
keySet.add(A_KEY);
keySet.add(A_KEY2);
Map<GenericKey, ValueAndTimestamp<GenericRow>> map = new HashMap<>();
map.put(A_KEY, VALUE_AND_TIMESTAMP1);
map.put(A_KEY2, VALUE_AND_TIMESTAMP2);
final KeyValueIterator iterator = new TestKeyValueIterator(keySet, map);
final QueryResult queryResult = QueryResult.forResult(iterator);
queryResult.setPosition(POSITION);
result.addResult(PARTITION, queryResult);
return result;
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderV1Test method shouldAddRowTimeAndTimeWindowedRowKeyColumnsToLegacyStream.
@Test
public void shouldAddRowTimeAndTimeWindowedRowKeyColumnsToLegacyStream() {
// Given:
givenWindowedSourceStream(LEGACY_PSEUDOCOLUMN_VERSION_NUMBER);
final ValueTransformerWithKey<Windowed<GenericKey>, GenericRow, GenericRow> transformer = getTransformerFromStreamSource(windowedStreamSource);
final Windowed<GenericKey> key = new Windowed<>(KEY, new TimeWindow(A_WINDOW_START, A_WINDOW_END));
// When:
final GenericRow withTimestamp = transformer.transform(key, row);
// Then:
assertThat(withTimestamp, equalTo(GenericRow.genericRow("baz", 123, HEADER_DATA, A_ROWTIME, A_KEY, A_WINDOW_START, A_WINDOW_END)));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class SourceBuilderV1Test method shouldHandleEmptyKeyLegacy.
@Test
public void shouldHandleEmptyKeyLegacy() {
// Given:
givenUnwindowedSourceStream(LEGACY_PSEUDOCOLUMN_VERSION_NUMBER);
final ValueTransformerWithKey<GenericKey, GenericRow, GenericRow> transformer = getTransformerFromStreamSource(streamSource);
final GenericKey nullKey = GenericKey.genericKey((Object) null);
// When:
final GenericRow withTimestamp = transformer.transform(nullKey, row);
// Then:
assertThat(withTimestamp, equalTo(GenericRow.genericRow("baz", 123, HEADER_DATA, A_ROWTIME, null)));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class StreamAggregateBuilderTest method shouldBuildUnwindowedAggregateCorrectly.
@Test
public void shouldBuildUnwindowedAggregateCorrectly() {
// Given:
givenUnwindowedAggregate();
// When:
final KTableHolder<GenericKey> result = aggregate.build(planBuilder, planInfo);
// Then:
assertThat(result.getTable(), is(aggregatedWithResults));
final InOrder inOrder = Mockito.inOrder(groupedStream, aggregated, aggregatedWithResults);
inOrder.verify(groupedStream).aggregate(initializer, aggregator, materialized);
inOrder.verify(aggregated).transformValues(any(), any(Named.class));
inOrder.verifyNoMoreInteractions();
}
Aggregations