-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add duckdb_enum_values C API function to get enum dictionary strings #11704
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
Change API to return a duckdb_state and use an out parameter for set length.
seems to missing an include for |
I don't understand the build. I was able to run the tests and build it. But I changed |
Thanks for the PR! Can't the same behavior be accomplished by using In general we want to keep the C API lean and not add functions unnecessarily. It is not meant to be nice to use stand-alone but rather meant as a building block for other APIs, so if the functionality is available elsewhere adding extra functions is not desirable. |
@Mytherin What about adding a function that takes an enum member name and returns its numeric value? Similar to |
Sure, that makes sense |
You know...I didn't want to couple the size of the dictionary to the underlying enum value. I figured the two might not always be tightly coupled: what if you were allowed to drop an enum value, then you'd have a hole. But I realize that might implementation has the same baked-in coupling by depending on the index of the array...So sorry. |
No need to apologize. The logical type contains the type after catalog resolution, so a drop/create of the enum value would not affect it as we are not going back to the catalog between these steps. As such that scenario will work correctly in both cases. |
This adds a
duckdb_enum_values
function to the C-API. It populates the passed-inchar**
with the enum string values, preserving the insertion order. This allows a driver to accept a string value and map it to the internal integer representation. I plan on using in my Zig driver to allow string values to be appended to enum columns (using the existingduckdb_append_data_chunk
).