Skip to content

Commit

Permalink
[FLINK-35700][cli] Loosen CDC pipeline options validation
Browse files Browse the repository at this point in the history
This closes  #3435.
  • Loading branch information
yuxiqian authored Jun 26, 2024
1 parent 3441a1e commit 0723009
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@
package org.apache.flink.cdc.composer.definition;

import org.apache.flink.cdc.common.annotation.VisibleForTesting;
import org.apache.flink.cdc.common.configuration.ConfigOption;
import org.apache.flink.cdc.common.configuration.Configuration;
import org.apache.flink.cdc.common.pipeline.PipelineOptions;
import org.apache.flink.cdc.common.types.LocalZonedTimestampType;
import org.apache.flink.cdc.composer.PipelineComposer;
import org.apache.flink.cdc.composer.PipelineExecution;
import org.apache.flink.table.api.ValidationException;

import java.time.ZoneId;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import java.util.stream.Collectors;

import static org.apache.flink.cdc.common.pipeline.PipelineOptions.PIPELINE_LOCAL_TIME_ZONE;

Expand Down Expand Up @@ -73,8 +67,6 @@ public PipelineDef(
this.routes = routes;
this.transforms = transforms;
this.config = evaluatePipelineTimeZone(config);

validatePipelineDefinition(this.config);
}

public SourceDef getSource() {
Expand Down Expand Up @@ -138,43 +130,6 @@ public int hashCode() {
// Utilities
// ------------------------------------------------------------------------

@VisibleForTesting
public static void validatePipelineDefinition(Configuration configuration)
throws ValidationException {
List<ConfigOption<?>> options =
Arrays.asList(
PipelineOptions.PIPELINE_NAME,
PipelineOptions.PIPELINE_PARALLELISM,
PipelineOptions.PIPELINE_SCHEMA_CHANGE_BEHAVIOR,
PipelineOptions.PIPELINE_LOCAL_TIME_ZONE,
PipelineOptions.PIPELINE_SCHEMA_OPERATOR_UID,
PipelineOptions.PIPELINE_SCHEMA_OPERATOR_RPC_TIMEOUT);

Set<String> optionKeys =
options.stream().map(ConfigOption::key).collect(Collectors.toSet());

configuration
.getKeys()
.forEach(
key -> {
if (!optionKeys.contains(key)) {
throw new ValidationException(
String.format("Unknown configuration key `%s`", key));
}
});

options.forEach(
option -> {
if (!configuration.getOptional(option).isPresent()
&& !option.hasDefaultValue()) {
throw new ValidationException(
String.format(
"Configuration key `%s` is not specified, and no default value available.",
option.key()));
}
});
}

/**
* Returns the current session time zone id. It is used when converting to/from {@code TIMESTAMP
* WITH LOCAL TIME ZONE}.
Expand Down

This file was deleted.

0 comments on commit 0723009

Please sign in to comment.