Address Bug Related to Map fields Containing Multiple Entries in DataTypeTransformer#13265
Address Bug Related to Map fields Containing Multiple Entries in DataTypeTransformer#13265aishikbh wants to merge 2 commits into
Conversation
* Fix for a bug where map type is passed as singlevalue when the value of the map contains a list or Object[]
aa57ce6 to
35f8265
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #13265 +/- ##
============================================
+ Coverage 61.75% 62.17% +0.42%
+ Complexity 207 198 -9
============================================
Files 2436 2534 +98
Lines 133233 139051 +5818
Branches 20636 21554 +918
============================================
+ Hits 82274 86458 +4184
- Misses 44911 46121 +1210
- Partials 6048 6472 +424
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
7eadc1c to
874b395
Compare
* Add ways to handle further multivalued lists/maps/collections
874b395 to
c6f28a4
Compare
|
|
||
| // Check if the value itself is multivalued. | ||
| if (singleValue instanceof Object[] || singleValue instanceof List) { | ||
| standardizedValue = standardize(column, singleValue, false); |
There was a problem hiding this comment.
I don't think this is correct. This can result in nested arrays being generated, and break the following part.
What you can do is to generate all standardized values for every elements, and continue when:
- There is no
Object[] - There is only one
Object[], no other value (allnulls)
The same logic also applies to collections and map. But before getting into that, I'd invest why are we getting multiple nested arrays
There was a problem hiding this comment.
Agreed. On further inspection ComplexTypeConfig should be used to decipher such objects. Closing the PR since by the time the data comes to DataTypeTransformer it shouldn't be in this state (nested array, multi key multivalue map etc)
Issue
In
standardizemethod ofDataTypeTransformer, we loop through the values if the value itself is an instance ofobject[], we process each of the values ofobject[]and set theisSingleValuefactor true assuming every value here issingleValueand again callstandardize. We will get an exception in the case where the value field of a map is multivalued.We will get an exception when 1. The map has multiple key entries and 2. If either values of the key entries are multivalue (
ListorObject[])Example Code to Recreate the Issue:
Thrown exception :
Solution
Detect multivalued entries in the Object[] and modify the
isSingleValuefield accordingly.