fix: cast map types correctly in schema adapter#1771
Conversation
|
Marking as draft. Spark diffs may need to be updated as well. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1771 +/- ##
============================================
+ Coverage 56.12% 58.59% +2.46%
- Complexity 976 1131 +155
============================================
Files 119 130 +11
Lines 11743 12667 +924
Branches 2251 2363 +112
============================================
+ Hits 6591 7422 +831
- Misses 4012 4061 +49
- Partials 1140 1184 +44 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This is ready for review. Fixes 16 test failures in core2 (both native_datafusion and native_iceberg_compat) without any regressions |
andygrove
left a comment
There was a problem hiding this comment.
LGTM. Thanks @parthchandra!
|
|
||
| /// Cast a map type to another map type. The same as arrow-cast except we recursively call our own | ||
| /// cast_array | ||
| pub(crate) fn cast_map_values( |
There was a problem hiding this comment.
do we really need pub(crate)?
comphead
left a comment
There was a problem hiding this comment.
Thanks @parthchandra
however I feel we need to add some more later. the test passed because
checkSparkAnswer(spark.sql("SELECT map_keys(map1).id2 FROM tbl"))
and will prob fail for
checkSparkAnswerAndOperator(spark.sql("SELECT map_keys(map1).id2 FROM tbl"))
|
in followup PR I'll add a rust test case for map |
8eb843a to
f22c55e
Compare
Good point @comphead . The test cannot use with DSV1 sources, the scan is Native but the Project is not. |
|
Filed #1781 |
Which issue does this PR close?
Closes #1754
Rationale for this change
In schema_adapter Map types are cast using arrow's cast which assumes that all nested fields within the map are also castable. However, the check to verify if the fields can be cast does not take into account nested struct fields with a different number of fields.
What changes are included in this PR?
The PR changes the cast method to a copy of the original that calls the schema adapter's struct cast method which can handle such structs
How are these changes tested?
Unit test was already added. This PR enables the test