Skip to content
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

Question: Is there no way to create a DictionaryArray with a pre-arranged mapping? #729

Closed
jmrgibson opened this issue Aug 30, 2021 · 3 comments
Labels
question Further information is requested

Comments

@jmrgibson
Copy link

It would appear from the docs that you cannot create a DictionaryArray by defining both the keys and and values? This is opposed to the python API which does. This is quite useful for cases where the dictionary mapping is defined elsewhere (e.g., a C enum). Are there plans to add this? Or am I reading the docs wrong. Thanks!

@jmrgibson jmrgibson added the question Further information is requested label Aug 30, 2021
@jmrgibson jmrgibson changed the title Question: Is there no way to create a DictionaryArray with a pre-arrange mapping? Question: Is there no way to create a DictionaryArray with a pre-arranged mapping? Aug 30, 2021
@jhorstmann
Copy link
Contributor

There is StringDictionaryBuilder::new_with_dictionary which allows specifying existing dictionary values when building an array.

There is also a low-level way of building array from an underlying ArrayData struct, but this is much more complex than the python api you pointed too. So I agree, such an api would be quite useful.

@jmrgibson
Copy link
Author

Ah neat, yeah new_with_dictionary is what I wanted, I was just looking in the wrong place. Thanks!

@jhorstmann
Copy link
Contributor

For combining keys with an existing dictionary there is also PrimitiveBuilder::finish_dict. This is not that obvious to find in the documentation and I also forgot about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants