You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/10/29 09:19:13 UTC

[GitHub] [flink] PatrickRen commented on a change in pull request #17601: [FLINK-24697][flink-connectors-kafka] add auto.offset.reset configuration for group-offsets startup mode

PatrickRen commented on a change in pull request #17601:
URL: https://github.com/apache/flink/pull/17601#discussion_r739070733



##########
File path: flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaDynamicTableFactoryTest.java
##########
@@ -380,6 +381,44 @@ public void testTableSourceCommitOnCheckpointDisabled() {
                                 .noDefaultValue()));
     }
 
+    @Test
+    public void testTableSourceSetOffsetReset() {

Review comment:
       NIT: We can use parameterized test here after migrating to JUnit 5 😄 

##########
File path: flink-connectors/flink-connector-kafka/src/main/java/org/apache/flink/streaming/connectors/kafka/table/KafkaDynamicSource.java
##########
@@ -392,7 +394,15 @@ public int hashCode() {
                 kafkaSourceBuilder.setStartingOffsets(OffsetsInitializer.latest());
                 break;
             case GROUP_OFFSETS:
-                kafkaSourceBuilder.setStartingOffsets(OffsetsInitializer.committedOffsets());
+                String offsetResetConfig =
+                        properties.getProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG);
+                if (offsetResetConfig == null) {
+                    kafkaSourceBuilder.setStartingOffsets(OffsetsInitializer.committedOffsets());
+                } else {
+                    kafkaSourceBuilder.setStartingOffsets(
+                            OffsetsInitializer.committedOffsets(
+                                    getOffsetResetStrategy(offsetResetConfig)));

Review comment:
       What about using `OffsetResetStrategy.valueOf(offsetResetConfig.toUpperCase(Locale.ROOT))` ?




-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org