zhaohaidao commented on a change in pull request #8550: URL: https://github.com/apache/kafka/pull/8550#discussion_r418813975
########## File path: streams/src/test/java/org/apache/kafka/streams/kstream/internals/KStreamRepartitionTest.java ########## @@ -104,6 +114,54 @@ public void shouldInvokePartitionerWhenSet() { verify(streamPartitionerMock); } + @Test + public void shouldThrowAnExceptionWhenNumberOfPartitionsOfRepartitionOperationsDoNotMatchWhenJoining() { + final String topicB = "topic-b"; + final String outputTopic = "topic-output"; + final String topicBRepartitionedName = "topic-b-scale-up"; + final String inputTopicRepartitionedName = "input-topic-scale-up"; + final int topicBNumberOfPartitions = 2; + final int inputTopicNumberOfPartitions = 4; + final StreamsBuilder builder = new StreamsBuilder(); + + final Repartitioned<Integer, String> inputTopicRepartitioned = Repartitioned + .<Integer, String>as(inputTopicRepartitionedName) + .withNumberOfPartitions(inputTopicNumberOfPartitions); + + final Repartitioned<Integer, String> topicBRepartitioned = Repartitioned + .<Integer, String>as(topicBRepartitionedName) + .withNumberOfPartitions(topicBNumberOfPartitions); + + final KStream<Integer, String> topicBStream = builder + .stream(topicB, Consumed.with(Serdes.Integer(), Serdes.String())) + .repartition(topicBRepartitioned); + + builder.stream(inputTopic, Consumed.with(Serdes.Integer(), Serdes.String())) + .repartition(inputTopicRepartitioned) + .join(topicBStream, (value1, value2) -> value2, JoinWindows.of(Duration.ofSeconds(10))) + .to(outputTopic); + + final Map<String, Integer> repartitionTopicsWithNumOfPartitions = Utils.mkMap( + Utils.mkEntry(toRepartitionTopicName(topicBRepartitionedName), topicBNumberOfPartitions), + Utils.mkEntry(toRepartitionTopicName(inputTopicRepartitionedName), inputTopicNumberOfPartitions) + ); + + try { + builder.build(props); + Assert.fail(); + } catch (final TopologyException t) { Review comment: Done ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org