-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Variant] feat: add support for casting MapArray to VariantArray #8177
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
Conversation
alamb
left a comment
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.
Thank you @Weijun-H -- I have some questions
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.
This seems to have created something like
[{
"keys": "key1",
"values": 1
}]I expect the result to be
{ "key1": 1 }Questions:
- where did the list come from?
- I am not sure about the "keys" and "values" fields 🤔
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.
Since there is no data type in Variant that can directly represent a map,
I converted the map into the following structure:
[
{
"keys": "key1",
"values": 1
},
{
"keys": "key2",
"values": 2
}
]
Using an object might be a better idea, but the keys can only be strings. 🤔
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.
I think object is the more expected result
Maybe you can all the keys of the MapArray into strings using the cast_to_variant kernel ?
7dd5aaa to
85eabb0
Compare
38a0b4e to
60c56ff
Compare
alamb
left a comment
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.
Thanks @Weijun-H -- this is looking good
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.
We could also potentially cast this directly to a string aray here, somethin glike
| let keys = cast_to_variant(map_array.keys())?; | |
| let keys = cast(map_array.keys(), DataType::Utf8)?; |
And then you wouldn't have to worry about dealing with Variants
I think what you have here, other than the unwrap, is looks good to me
5fc2ef2 to
e85a41d
Compare
e85a41d to
ff5f64e
Compare
alamb
left a comment
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.
Thank you @Weijun-H
|
I merged up to resolve a conflict |
|
Thanks. again @Weijun-H |
Which issue does this PR close?
DataType::Mapsupport forcast_to_variantkernel #8063Rationale for this change
Maps are now cast to
Variant::ObjectsWhat changes are included in this PR?
Are these changes tested?
Yes
Are there any user-facing changes?