Fix Parquet/Avro list struct MV expanded as array of maps#17708
Open
rsrkpatwari1234 wants to merge 3 commits intoapache:masterfrom
Open
Fix Parquet/Avro list struct MV expanded as array of maps#17708rsrkpatwari1234 wants to merge 3 commits intoapache:masterfrom
rsrkpatwari1234 wants to merge 3 commits intoapache:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #17708 +/- ##
============================================
- Coverage 63.20% 63.20% -0.01%
Complexity 1499 1499
============================================
Files 3179 3179
Lines 190696 190709 +13
Branches 29151 29155 +4
============================================
+ Hits 120525 120532 +7
- Misses 60797 60802 +5
- Partials 9374 9375 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Problem
When Parquet/Avro store a list as an array of structs with a single field "element", the record extractor was leaving them as arrays of single-key maps instead of unwrapping to plain arrays. For example:
Expected: "metadata": {"tags": ["abc", "xyz"]}
Actual: "metadata": {"tags": [{"element":"abc"}, {"element":"xyz"}]}
This breaks schemas and queries that expect multi-value columns to be arrays of scalars.
Solution
BaseRecordExtractor: After building a multi-value array from a Collection or Object[], run it through a new helper unwrapElementMapsInArray(). If every element is a Map with exactly one key "element", replace the array with the values of that key; otherwise leave the array unchanged. Do not apply unwrapping to primitive arrays.
Tests
Added BaseRecordExtractorTest with 8 cases covering unwrap when all elements are single-key "element" maps, no unwrap for mixed/multi-key/different-key/primitive/empty, and a full-path extract() test.
Scope
Change is in pinot-spi; any record reader that extends BaseRecordExtractor gets the fix.
Primitive arrays and non–element-map arrays are unchanged.
Fixes #17420