Fix dataframe_to_mds for non-nullable ArrayType columns#984
Open
discobot wants to merge 1 commit into
Open
Conversation
PySpark ArrayType equality includes containsNull, so the SPARK_TO_MDS lookup missed array columns declared with containsNull=False (e.g. produced by concat/array over non-null columns) and raised 'is not supported by dataframe_to_mds'. Normalize the lookup to the element type only, mirroring the existing DecimalType handling. Adds regression tests covering schema inference and end-to-end conversion for non-nullable arrays.
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 of changes:
dataframe_to_mdsrejects array columns declared withcontainsNull=False, as reported in the issue.This PR implements the element-type lookup suggested there:
map_spark_dtypenow normalizes arrays toArrayType(elementType)before theSPARK_TO_MDSlookup, mirroring the existingDecimalTypenormalization directly above. Both call sites are covered (user-defined-columns validation and automatic schema inference), and the change is safe because the MDSndarray:*encodings don't depend on array nullability.Added regression tests: schema inference on a
containsNull=Falsearray column, plus end-to-end conversion with both auto-inferred and user-defined columns. They fail without the source change; with it,tests/base/converters/test_dataframe_to_mds.pypasses locally (24 passed).Issue #, if available:
Merge Checklist:
Put an
xwithout space in the boxes that apply. If you are unsure about any checklist, please don't hesitate to ask. We are here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
pre-commiton my change. (check out thepre-commitsection of prerequisites)Authored with the help of Claude Code.