mithun-sudo commented on code in PR #18066:
URL: https://github.com/apache/iceberg/pull/18066#discussion_r4026513564


##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DataConverter.java:
##########
@@ -232,4 +239,24 @@ public MapData convert(Object object) {
       return new GenericMapData(convertedMap);
     }
   }
+
+  private static int findFieldIndex(RowType sourceType, String targetName, 
boolean caseSensitive) {
+    if (caseSensitive) {
+      return sourceType.getFieldIndex(targetName);
+    }
+
+    int matchingIndex = -1;
+    for (int i = 0; i < sourceType.getFieldCount(); i++) {
+      if 
(sourceType.getFields().get(i).getName().equalsIgnoreCase(targetName)) {
+        Preconditions.checkArgument(
+            matchingIndex == -1,
+            "Ambiguous case-insensitive source field match for '%s' in %s",
+            targetName,
+            sourceType);

Review Comment:
   This path now throws IllegalArgumentException only after a duplicate is 
found and the message includes both source field names.
   
   Moved away from Preconditions.checkArgument  because it evaluates message 
args even when the check passes, so get(matchingIndex) would call get(-1) on 
the first match. 
   
   



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