Hisoka-X commented on code in PR #7549:
URL: https://github.com/apache/seatunnel/pull/7549#discussion_r1740662600


##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/utils/SchemaUtil.java:
##########
@@ -69,9 +71,14 @@ public static Column 
toSeaTunnelType(BasicTypeDefine<DataType> typeDefine) {
     }
 
     public static DataField getDataField(List<DataField> fields, String 
fieldName) {
-        return fields.parallelStream()
-                .filter(field -> field.name().equals(fieldName))
-                .findFirst()
-                .get();
+        Optional<DataField> firstField =
+                fields.parallelStream().filter(field -> 
field.name().equals(fieldName)).findFirst();
+        if (firstField.isPresent()) {
+            return firstField.get();
+        }
+        throw new SeaTunnelException(
+                String.format(
+                        "Con not get the DataField named: [%s] in sink schema. 
The schema of paimon is case-sensitive in default. Please check it.",
+                        fieldName));

Review Comment:
   Why not just list `fields` values in exception message? `case not match` 
just only one situation which can cause this exception.
   You can reuse this error:
   
https://github.com/apache/seatunnel/blob/c46e16a128fa7ac5a4f2c507296a882279182a10/seatunnel-common/src/main/java/org/apache/seatunnel/common/exception/CommonError.java#L251



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