Skip to content

Commit

Permalink
[improve][io] Support update subscription position for sink connector (
Browse files Browse the repository at this point in the history
  • Loading branch information
shibd authored Nov 5, 2024
1 parent 7a47888 commit 3f12269
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,9 @@ public static SinkConfig validateUpdate(SinkConfig existingConfig, SinkConfig ne
if (newConfig.getTransformFunctionConfig() != null) {
mergedConfig.setTransformFunctionConfig(newConfig.getTransformFunctionConfig());
}

if (newConfig.getSourceSubscriptionPosition() != null) {
mergedConfig.setSourceSubscriptionPosition(newConfig.getSourceSubscriptionPosition());
}
return mergedConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.pulsar.client.api.SubscriptionInitialPosition;
import org.apache.pulsar.common.functions.ConsumerConfig;
import org.apache.pulsar.common.functions.FunctionConfig;
import org.apache.pulsar.common.functions.Resources;
Expand Down Expand Up @@ -224,6 +225,18 @@ public void testCleanSubscriptionField() throws IOException {
}
}

@Test
public void testUpdateSubscriptionPosition() {
SinkConfig sinkConfig = createSinkConfig();
SinkConfig newSinkConfig = createSinkConfig();
newSinkConfig.setSourceSubscriptionPosition(SubscriptionInitialPosition.Earliest);
SinkConfig mergedConfig = SinkConfigUtils.validateUpdate(sinkConfig, newSinkConfig);
assertEquals(
new Gson().toJson(newSinkConfig),
new Gson().toJson(mergedConfig)
);
}

@Test
public void testMergeEqual() {
SinkConfig sinkConfig = createSinkConfig();
Expand Down Expand Up @@ -565,6 +578,7 @@ private SinkConfig createSinkConfig() {
inputSpecs.put("test-input", ConsumerConfig.builder().isRegexPattern(true).serdeClassName("test-serde").build());
sinkConfig.setInputSpecs(inputSpecs);
sinkConfig.setProcessingGuarantees(FunctionConfig.ProcessingGuarantees.ATLEAST_ONCE);
sinkConfig.setSourceSubscriptionPosition(SubscriptionInitialPosition.Latest);
sinkConfig.setRetainOrdering(false);
sinkConfig.setRetainKeyOrdering(false);
sinkConfig.setConfigs(new HashMap<>());
Expand Down

0 comments on commit 3f12269

Please sign in to comment.