mjsax commented on code in PR #24015:
URL: https://github.com/apache/kafka/pull/24015#discussion_r4419104170


##########
streams/src/test/java/org/apache/kafka/streams/kstream/internals/KTableKTableForeignKeyJoinScenarioTest.java:
##########
@@ -376,6 +378,43 @@ public void 
shouldWorkWithCompositeKeyAndBiFunctionExtractor(final boolean withH
         }
     }
 
+    @ParameterizedTest
+    @ValueSource(booleans = {false, true})
+    public void shouldNotFailOnInvalidPartitionInSubscription(final boolean 
withHeaders) {
+        final StreamsBuilder builder = new StreamsBuilder();
+        final KTable<Integer, String> left = builder.table(LEFT_TABLE, 
Consumed.with(Serdes.Integer(), Serdes.String()));
+        final KTable<Integer, String> right = builder.table(RIGHT_TABLE, 
Consumed.with(Serdes.Integer(), Serdes.String()));
+        left.join(
+            right,
+            value -> Integer.parseInt(value.split("\\|")[1]),
+            (value1, value2) -> "(" + value1 + "," + value2 + ")",
+            TableJoined.as("fk-join")
+        ).toStream().to(OUTPUT, Produced.with(Serdes.Integer(), 
Serdes.String()));
+
+        try (final TopologyTestDriver driver = 
createTopologyTestDriver(builder, withHeaders)) {
+            final TestInputTopic<Integer, String> leftInput = 
driver.createInputTopic(LEFT_TABLE, new IntegerSerializer(), new 
StringSerializer());
+            final TestInputTopic<Integer, String> rightInput = 
driver.createInputTopic(RIGHT_TABLE, new IntegerSerializer(), new 
StringSerializer());
+            final TestOutputTopic<Integer, String> output = 
driver.createOutputTopic(OUTPUT, new IntegerDeserializer(), new 
StringDeserializer());
+            final TestInputTopic<Integer, SubscriptionWrapper<Integer>> 
subscriptionInput = driver.createInputTopic(
+                "test-app-fk-join-subscription-registration-topic",
+                new IntegerSerializer(),
+                new SubscriptionWrapperSerde<>(() -> "pk-pseudo-topic", 
Serdes.Integer()).serializer()
+            );
+
+            rightInput.pipeInput(1, "rhsValue1");
+            leftInput.pipeInput(2, "lhsValue1|1");
+            assertEquals(Map.of(2, "(lhsValue1|1,rhsValue1)"), 
output.readKeyValuesToMap());
+
+            subscriptionInput.pipeInput(1, new SubscriptionWrapper<>(
+                new long[] {1L, 2L},

Review Comment:
   Claude found an issue with this...
   
   ```
     The scenario test can't tell whether the fallback works. It writes a 
subscription with hash {1L, 2L}, so the response is dropped for a hash 
mismatch, and
     output.isEmpty() would pass no matter where the response went. All it 
proves is that nothing crashes. A stronger version would use the real hash of 
"lhsValue1|1",
     computed with Murmur3.hash128 over the serialized value, and assert that 
the join result comes out. TTD only has one partition here, so even that can't 
check routing; it
     only shows the fallback delivers the response. I haven't checked whether 
headers mode changes the hash input, so confirm that for the withHeaders=true 
case. If the
     producer-side fix happens, a test using processValues plus a punctuator 
would cover the real path from start to finish.
   ```



-- 
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]

Reply via email to