scwhittle commented on code in PR #31682: URL: https://github.com/apache/beam/pull/31682#discussion_r1736065201
########## sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/KafkaIO.java: ########## @@ -2684,26 +2687,49 @@ public PCollection<KafkaRecord<K, V>> expand(PCollection<KafkaSourceDescriptor> .getSchemaRegistry() .getSchemaCoder(KafkaSourceDescriptor.class), recordCoder)); + if (isCommitOffsetEnabled() && !configuredKafkaCommit() && !isRedistribute()) { - outputWithDescriptor = - outputWithDescriptor - .apply(Reshuffle.viaRandomKey()) - .setCoder( - KvCoder.of( - input - .getPipeline() - .getSchemaRegistry() - .getSchemaCoder(KafkaSourceDescriptor.class), - recordCoder)); - - PCollection<Void> unused = outputWithDescriptor.apply(new KafkaCommitOffset<K, V>(this)); - unused.setCoder(VoidCoder.of()); + // Add transform for committing offsets to Kafka with consistency with beam pipeline data + // processing. + boolean useLegacyImplementation = false; + String requestedVersionString = + input + .getPipeline() + .getOptions() + .as(StreamingOptions.class) + .getUpdateCompatibilityVersion(); + if (requestedVersionString != null) { + List<String> requestedVersion = Arrays.asList(requestedVersionString.split("\\.")); + List<String> targetVersion = Arrays.asList("2", "59", "0"); + + if (Comparators.lexicographical(Comparator.<String>naturalOrder()) + .compare(requestedVersion, targetVersion) + < 0) { + useLegacyImplementation = true; Review Comment: Modified PTAL. Fixed the test serialization issue. Running some manual update compatability checks. -- 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: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org