-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MapType as JSON-compatible #776
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nits.
If possible can you add a simple unit test?
I think this is otherwise good to go - there are existing and one new test. I can add more too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit: variable name change. otherwise lgtm
@snarayan21 said I could merge after that change, so here goes! |
Description of changes:
dataframe_to_mds
does not directly support the Spark Map type as there is no direct analog in streaming (?)However, the dataframe_to_mds will accept "unsupported" Spark types if they are JSON-compatible, and if the user specifies type 'json' for the column.
However the logic of
is_json_compatible
doesn't includeMapType
, when a map is conceptually fine as a dict, and Spark uses simple dicts to represent such maps in pandas DFs. As long as the map's key and value types are JSON compatible, it should be considered JSON compatible.With this change, it's possible to have columns including a map type successfully convert to JSON in an MDS file if the given type for the column is specified as 'json'.
Merge Checklist:
General
Tests
pre-commit
on my change. (check out thepre-commit
section of prerequisites)