JNSimba commented on code in PR #490:
URL: 
https://github.com/apache/doris-flink-connector/pull/490#discussion_r1764799170


##########
flink-doris-connector/src/main/java/org/apache/doris/flink/sink/schema/SchemaChangeManager.java:
##########
@@ -214,15 +234,42 @@ private boolean handleSchemaChange(String responseEntity) 
throws JsonProcessingE
         }
     }
 
+    private String getDefaultValue(String ddl, String database, String column)
+            throws IOException, IllegalArgumentException {
+        String responseEntity = executeThenReturnResponse(ddl, database);
+        JsonNode responseNode = objectMapper.readTree(responseEntity);
+        String code = responseNode.get("code").asText("-1");
+        if (code.equals("0")) {
+            JsonNode data = responseNode.get("data").get("data");
+            for (JsonNode node : data) {
+                if (node.get(0).asText().equals(column)) {
+                    JsonNode defaultValueNode = node.get(5);
+                    return (defaultValueNode instanceof NullNode)
+                            ? null
+                            : defaultValueNode.asText();
+                }
+            }
+            return null;
+        } else {
+            throw new DorisSchemaChangeException(
+                    "Failed to get default value, response: " + 
responseEntity);
+        }
+    }
+
     /** execute sql in doris. */
-    public boolean execute(String ddl, String database)
+    public String executeThenReturnResponse(String ddl, String database)
             throws IOException, IllegalArgumentException {
         if (StringUtils.isNullOrWhitespaceOnly(ddl)) {
-            return false;
+            return null;

Review Comment:
   May cause NPE in method handleSchemaChange?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to