TyrantLucifer commented on code in PR #3896:
URL: 
https://github.com/apache/incubator-seatunnel/pull/3896#discussion_r1071750702


##########
seatunnel-connectors-v2/connector-iotdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/source/IoTDBSource.java:
##########
@@ -65,21 +65,29 @@ public String getPluginName() {
 
     @Override
     public void prepare(Config pluginConfig) throws PrepareFailException {
-        CheckResult result = CheckConfigUtil.checkAllExists(pluginConfig, 
HOST.key(), PORT.key());
-        if (!result.isSuccess()) {
-            result = CheckConfigUtil.checkAllExists(pluginConfig, 
NODE_URLS.key());
-
-            if (!result.isSuccess()) {
-                throw new 
IotdbConnectorException(SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
-                    String.format("PluginName: %s, PluginType: %s, Message: 
%s",
-                        getPluginName(), PluginType.SOURCE,
-                        result.getMsg())
-                );
-            }
+        CheckResult urlCheckResult = 
CheckConfigUtil.checkAllExists(pluginConfig, HOST.key(), PORT.key());
+        if (!urlCheckResult.isSuccess()) {
+            urlCheckResult = CheckConfigUtil.checkAllExists(pluginConfig, 
NODE_URLS.key());
+        }
+        CheckResult schemaCheckResult = 
CheckConfigUtil.checkAllExists(pluginConfig, SeaTunnelSchema.SCHEMA.key());
+        CheckResult mergedConfigCheck = 
CheckConfigUtil.mergeCheckResults(urlCheckResult, schemaCheckResult);
+        if (!mergedConfigCheck.isSuccess()) {
+            throw new 
IotdbConnectorException(SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
+                String.format("PluginName: %s, PluginType: %s, Message: %s",
+                    getPluginName(), PluginType.SOURCE,
+                    mergedConfigCheck.getMsg())
+            );
+        }
+        try {
+            Config schemaConfig = 
pluginConfig.getConfig(SeaTunnelSchema.SCHEMA.key());
+            this.typeInfo = 
SeaTunnelSchema.buildWithConfig(schemaConfig).getSeaTunnelRowType();
+            pluginConfig.entrySet().forEach(entry -> 
configParams.put(entry.getKey(), entry.getValue().unwrapped()));
+        } catch (Exception e) {
+            throw new 
IotdbConnectorException(SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
+                String.format("PluginName: %s, PluginType: %s, Message: %s",
+                    getPluginName(), PluginType.SOURCE, e)
+            );
         }

Review Comment:
   ```suggestion
           SeaTunnelSchema seatunnelSchema = 
SeaTunnelSchema.buildWithConfig(pluginConfig);
           this.typeInfo = seatunnelSchema.getSeaTunnelRowType();
           pluginConfig.entrySet().forEach(entry -> 
configParams.put(entry.getKey(), entry.getValue().unwrapped()));
   ```



##########
seatunnel-connectors-v2/connector-iotdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/source/IoTDBSourceFactory.java:
##########
@@ -49,7 +50,7 @@ public String factoryIdentifier() {
     @Override
     public OptionRule optionRule() {
         return OptionRule.builder()
-                .required(NODE_URLS, USERNAME, PASSWORD, SQL)
+                .required(NODE_URLS, USERNAME, PASSWORD, SQL, 
SeaTunnelSchema.SCHEMA)

Review Comment:
   static import is better



##########
seatunnel-connectors-v2/connector-iotdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/source/IoTDBSource.java:
##########
@@ -65,21 +65,29 @@ public String getPluginName() {
 
     @Override
     public void prepare(Config pluginConfig) throws PrepareFailException {
-        CheckResult result = CheckConfigUtil.checkAllExists(pluginConfig, 
HOST.key(), PORT.key());
-        if (!result.isSuccess()) {
-            result = CheckConfigUtil.checkAllExists(pluginConfig, 
NODE_URLS.key());
-
-            if (!result.isSuccess()) {
-                throw new 
IotdbConnectorException(SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
-                    String.format("PluginName: %s, PluginType: %s, Message: 
%s",
-                        getPluginName(), PluginType.SOURCE,
-                        result.getMsg())
-                );
-            }
+        CheckResult urlCheckResult = 
CheckConfigUtil.checkAllExists(pluginConfig, HOST.key(), PORT.key());
+        if (!urlCheckResult.isSuccess()) {
+            urlCheckResult = CheckConfigUtil.checkAllExists(pluginConfig, 
NODE_URLS.key());
+        }
+        CheckResult schemaCheckResult = 
CheckConfigUtil.checkAllExists(pluginConfig, SeaTunnelSchema.SCHEMA.key());
+        CheckResult mergedConfigCheck = 
CheckConfigUtil.mergeCheckResults(urlCheckResult, schemaCheckResult);
+        if (!mergedConfigCheck.isSuccess()) {
+            throw new 
IotdbConnectorException(SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
+                String.format("PluginName: %s, PluginType: %s, Message: %s",
+                    getPluginName(), PluginType.SOURCE,
+                    mergedConfigCheck.getMsg())
+            );
+        }
+        try {
+            Config schemaConfig = 
pluginConfig.getConfig(SeaTunnelSchema.SCHEMA.key());
+            this.typeInfo = 
SeaTunnelSchema.buildWithConfig(schemaConfig).getSeaTunnelRowType();
+            pluginConfig.entrySet().forEach(entry -> 
configParams.put(entry.getKey(), entry.getValue().unwrapped()));
+        } catch (Exception e) {
+            throw new 
IotdbConnectorException(SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,
+                String.format("PluginName: %s, PluginType: %s, Message: %s",
+                    getPluginName(), PluginType.SOURCE, e)
+            );
         }

Review Comment:
   Revert this logic. As is.



-- 
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]

Reply via email to