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.getConfig(SeaTunnelSchema.SCHEMA.key()));
           this.typeInfo = seatunnelSchema.getSeaTunnelRowType();
           pluginConfig.entrySet().forEach(entry -> 
configParams.put(entry.getKey(), entry.getValue().unwrapped()));
   ```



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