Kafka Connect: Fix case-insensitive field lookup with name mapping - #17454
Open
annurahar wants to merge 2 commits into
Open
Kafka Connect: Fix case-insensitive field lookup with name mapping#17454annurahar wants to merge 2 commits into
annurahar wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a bug where the
iceberg.tables.schema-case-insensitiveconfiguration is ignored when name mapping (schema.name-mapping.default) is present inRecordConverter.Problem
When both name mapping and case-insensitive mode are configured, the
lookupStructFieldmethod does not apply case-insensitive logic for field lookups. This causes fields with case differences (e.g.,"II"vs"ii") to fail matching the existing column.During schema evolution, the unmatched field is treated as a new field, causing a duplicate column to be added to the table. This results in unintended schema changes with redundant columns and data written to wrong columns.
Solution
Modified
lookupStructFieldandcreateStructNameMapmethods to respect theschemaCaseInsensitiveconfiguration when name mapping is present:createStructNameMap: Store keys in lowercase when case-insensitive mode is enabledlookupStructField: Convert the lookup key to lowercase when case-insensitive mode is enabledChanges
Testing
Added comprehensive test cases in
TestRecordConverter.java:testNameMappingWithDifferentCaseAlias- Tests field lookup with alias in different case (parameterized for case-sensitive/insensitive)testNameMappingWithNestedStruct- Tests nested struct field lookup with case sensitivity (parameterized)testLookupStructFieldWithNameMappingAndCaseSensitivity- Explicit test forlookupStructFieldbehavior with name mapping and both case sensitivity modesChecklist
Related Issue
Closes: #15392
This a new PR for stale PR - #15393