diff --git a/src/main/java/io/debezium/connector/jdbc/dialect/db2/Db2DatabaseDialect.java b/src/main/java/io/debezium/connector/jdbc/dialect/db2/Db2DatabaseDialect.java index 8c3af0b3..83c9c6d8 100644 --- a/src/main/java/io/debezium/connector/jdbc/dialect/db2/Db2DatabaseDialect.java +++ b/src/main/java/io/debezium/connector/jdbc/dialect/db2/Db2DatabaseDialect.java @@ -153,4 +153,18 @@ public String getFormattedTimestampWithTimeZone(String value) { return String.format("'%s'", DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(zonedDateTime)); } + @Override + protected String resolveColumnNameFromField(String fieldName) { + String columnName = super.resolveColumnNameFromField(fieldName); + if (!getConfig().isQuoteIdentifiers()) { + // There are specific use cases where we explicitly quote the column name, even if the + // quoted identifiers is not enabled, such as the Kafka primary key mode column names. + // If they're quoted, we shouldn't uppercase the column name. + if (!getIdentifierHelper().toIdentifier(columnName).isQuoted()) { + // Db2 defaults to uppercase for identifiers + columnName = columnName.toUpperCase(); + } + } + return columnName; + } }