Copilot commented on code in PR #9252:
URL: https://github.com/apache/seatunnel/pull/9252#discussion_r2067765591
##########
seatunnel-connectors-v2/connector-selectdb-cloud/src/main/java/org/apache/seatunnel/connectors/selectdb/config/SelectDBConfig.java:
##########
@@ -132,65 +45,27 @@ public class SelectDBConfig {
private Integer flushQueueSize;
private Properties StageLoadProps;
- public static SelectDBConfig loadConfig(Config pluginConfig) {
+ public static SelectDBConfig loadConfig(ReadonlyConfig pluginConfig) {
SelectDBConfig selectdbConfig = new SelectDBConfig();
- selectdbConfig.setLoadUrl(pluginConfig.getString(LOAD_URL.key()));
- selectdbConfig.setJdbcUrl(pluginConfig.getString(JDBC_URL.key()));
-
selectdbConfig.setClusterName(pluginConfig.getString(CLUSTER_NAME.key()));
- selectdbConfig.setUsername(pluginConfig.getString(USERNAME.key()));
- selectdbConfig.setPassword(pluginConfig.getString(PASSWORD.key()));
-
selectdbConfig.setTableIdentifier(pluginConfig.getString(TABLE_IDENTIFIER.key()));
-
selectdbConfig.setStageLoadProps(parseCopyIntoProperties(pluginConfig));
-
- if (pluginConfig.hasPath(SINK_LABEL_PREFIX.key())) {
-
selectdbConfig.setLabelPrefix(pluginConfig.getString(SINK_LABEL_PREFIX.key()));
- } else {
- selectdbConfig.setLabelPrefix(SINK_LABEL_PREFIX.defaultValue());
- }
- if (pluginConfig.hasPath(SINK_MAX_RETRIES.key())) {
-
selectdbConfig.setMaxRetries(pluginConfig.getInt(SINK_MAX_RETRIES.key()));
- } else {
- selectdbConfig.setMaxRetries(SINK_MAX_RETRIES.defaultValue());
- }
- if (pluginConfig.hasPath(SINK_ENABLE_2PC.key())) {
-
selectdbConfig.setEnable2PC(pluginConfig.getBoolean(SINK_ENABLE_2PC.key()));
- } else {
- selectdbConfig.setEnable2PC(SINK_ENABLE_2PC.defaultValue());
- }
- if (pluginConfig.hasPath(SINK_BUFFER_SIZE.key())) {
-
selectdbConfig.setBufferSize(pluginConfig.getInt(SINK_BUFFER_SIZE.key()));
- } else {
- selectdbConfig.setBufferSize(SINK_BUFFER_SIZE.defaultValue());
- }
- if (pluginConfig.hasPath(SINK_BUFFER_COUNT.key())) {
-
selectdbConfig.setBufferCount(pluginConfig.getInt(SINK_BUFFER_COUNT.key()));
- } else {
- selectdbConfig.setBufferCount(SINK_BUFFER_COUNT.defaultValue());
- }
- if (pluginConfig.hasPath(SINK_ENABLE_DELETE.key())) {
-
selectdbConfig.setEnableDelete(pluginConfig.getBoolean(SINK_ENABLE_DELETE.key()));
- } else {
- selectdbConfig.setEnableDelete(SINK_ENABLE_DELETE.defaultValue());
- }
- if (pluginConfig.hasPath(SINK_FLUSH_QUEUE_SIZE.key())) {
-
selectdbConfig.setFlushQueueSize(pluginConfig.getInt(SINK_FLUSH_QUEUE_SIZE.key()));
- } else {
-
selectdbConfig.setFlushQueueSize(SINK_FLUSH_QUEUE_SIZE.defaultValue());
+
selectdbConfig.setLoadUrl(pluginConfig.get(SelectDBSinkOptions.LOAD_URL));
+
selectdbConfig.setJdbcUrl(pluginConfig.get(SelectDBSinkOptions.JDBC_URL));
+
selectdbConfig.setClusterName(pluginConfig.get(SelectDBSinkOptions.CLUSTER_NAME));
+
selectdbConfig.setUsername(pluginConfig.get(SelectDBSinkOptions.USERNAME));
+
selectdbConfig.setPassword(pluginConfig.get(SelectDBSinkOptions.PASSWORD));
+
selectdbConfig.setTableIdentifier(pluginConfig.get(SelectDBSinkOptions.TABLE_IDENTIFIER));
+ if
(pluginConfig.getOptional(SelectDBSinkOptions.SELECTDB_SINK_CONFIG_PREFIX).isPresent())
{
+ Properties properties = new Properties();
+
properties.putAll(pluginConfig.get(SelectDBSinkOptions.SELECTDB_SINK_CONFIG_PREFIX));
+ selectdbConfig.setStageLoadProps(properties);
}
+
selectdbConfig.setLabelPrefix(pluginConfig.get(SelectDBSinkOptions.SINK_LABEL_PREFIX));
Review Comment:
[nitpick] Verify that the default value for SINK_LABEL_PREFIX is
consistently provided through pluginConfig to ensure that the label prefix is
never null.
```suggestion
selectdbConfig.setLabelPrefix(
pluginConfig.getOptional(SelectDBSinkOptions.SINK_LABEL_PREFIX)
.orElse("default_label_prefix"));
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]