guozhangwang commented on code in PR #18194:
URL: https://github.com/apache/kafka/pull/18194#discussion_r1885807235
##########
streams/src/main/java/org/apache/kafka/streams/kstream/internals/KTableImpl.java:
##########
@@ -1278,12 +1278,11 @@ private <VR, KO, VO> KTable<K, VR>
doJoinOnForeignKey(final KTable<KO, VO> forei
final String foreignTableJoinName = renamed
.suffixWithOrElseGet("-foreign-join-subscription", builder,
SUBSCRIPTION_PROCESSOR);
- final StatefulProcessorNode<KO, Change<VO>> foreignTableJoinNode = new
ForeignTableJoinNode<>(
Review Comment:
Just curious is the final goal to eventually remove `StatefulProcessorNode`
and only use `ProcessorGraphNode`?
##########
streams/src/test/java/org/apache/kafka/streams/StreamsBuilderTest.java:
##########
@@ -2153,6 +2154,84 @@ public void shouldWrapProcessorsForTableTableOuterJoin()
{
assertThat(counter.numConnectedStateStores(), CoreMatchers.is(3));
}
+ @Test
+ public void shouldWrapProcessorsForForeignKeyInnerJoin() {
+ final Map<Object, Object> props = dummyStreamsConfigMap();
+ props.put(PROCESSOR_WRAPPER_CLASS_CONFIG,
RecordingProcessorWrapper.class);
+
+ final WrapperRecorder counter = new WrapperRecorder();
+ props.put(PROCESSOR_WRAPPER_COUNTER_CONFIG, counter);
+
+ final StreamsBuilder builder = new StreamsBuilder(new
TopologyConfig(new StreamsConfig(props)));
+
+ final KTable<String, String> left = builder.table("input1",
Consumed.as("input1"));
+ final KTable<String, String> right = builder.table("input2",
Consumed.as("input2"));
+
+ left.join(right,
+ value -> value,
+ (v1, v2) -> v1 + v2,
+ TableJoined.as("join"),
+ Materialized.<String, String, KeyValueStore<Bytes,
byte[]>>as("materialized-store").withValueSerde(Serdes.String()))
+ .toStream(Named.as("toStream"))
+ .to("output", Produced.as("sink"));
+
+ builder.build();
+ assertThat(counter.numWrappedProcessors(), CoreMatchers.is(9));
+ assertThat(counter.wrappedProcessorNames().toString(),
counter.wrappedProcessorNames(), Matchers.containsInAnyOrder(
+ "input1",
+ "input2",
+ "join-foreign-join-subscription",
+ "join-subscription-join-foreign",
+ "join-subscription-registration-processor",
+ "join-subscription-receive",
+ "join-result",
+ "join-subscription-response-resolver",
+ "toStream"
+ ));
+
+ assertThat(counter.numUniqueStateStores(), CoreMatchers.is(4)); //
table1, table2, subscription store, and join materialized
+ assertThat(counter.numConnectedStateStores(), CoreMatchers.is(5));
+ }
+
+ @Test
+ public void shouldWrapProcessorsForForeignKeyLeftJoin() {
+ final Map<Object, Object> props = dummyStreamsConfigMap();
+ props.put(PROCESSOR_WRAPPER_CLASS_CONFIG,
RecordingProcessorWrapper.class);
+
+ final WrapperRecorder counter = new WrapperRecorder();
+ props.put(PROCESSOR_WRAPPER_COUNTER_CONFIG, counter);
+
+ final StreamsBuilder builder = new StreamsBuilder(new
TopologyConfig(new StreamsConfig(props)));
+
+ final KTable<String, String> left = builder.table("input1",
Consumed.as("input1"));
+ final KTable<String, String> right = builder.table("input2",
Consumed.as("input2"));
+
+ left.leftJoin(right,
+ value -> value,
+ (v1, v2) -> v1 + v2,
+ TableJoined.as("l-join"),
+ Materialized.<String, String, KeyValueStore<Bytes,
byte[]>>as("materialized-store").withValueSerde(Serdes.String()))
+ .toStream(Named.as("toStream")) // 6
Review Comment:
What the comment `// 6` is about? I think this test case still only have 5
store?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]