[Variant] feat: add support for casting MapArray to VariantArray#8177
[Variant] feat: add support for casting MapArray to VariantArray#8177alamb merged 8 commits intoapache:mainfrom
Conversation
There was a problem hiding this comment.
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.
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.
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
There was a problem hiding this comment.
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
|
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?