public static void checkDuplicates(String[] fieldNames) {
        Set<String> items = new HashSet<>(fieldNames.length);
        Set<String> duplicatedFieldNames =
                Arrays.stream(fieldNames)
                        .filter(fieldName -> !items.add(fieldName))
                        .collect(Collectors.toSet());

        if (!duplicatedFieldNames.isEmpty()) {
            throw new IllegalArgumentException(String.format("There exist duplicated " +
                    "field names: %s", duplicatedFieldNames));
        }
    }
Check whether there are duplicated field names. Throws an {@link IllegalArgumentException}
with the duplicated field names if any exist.

@param fieldNames the field names to be checked.
inlong-sort/sort-formats/format-rowdata/format-rowdata-base/src/main/java/org/apache/inlong/sort/formats/util/FormatUtils.java