You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to have the option to retrieve the underlying index values from an ENUM-typed column using SQL. Perhaps this could be done by explicitly casting the column to an int?
For instance, given the following setup code:
CREATETYPEmoodAS ENUM ('sad', 'ok', 'happy');
CREATETABLEperson (
name text,
current_mood mood
);
INSERT INTO person VALUES ('Moe','happy'), ('Dave', NULL), ('Larry', 'sad'), ('Curly, 'ok');
And this query:
SELECT
name, CAST(current_mood ASINTEGER) AS mood_index
FROM
person;
The results would look like:
name
mood_index
Moe
2
Dave
NULL
Larry
0
Curly
1
Apologies if there's already a way to do this which I've missed. And thanks so much for DuckDB! It's a staggeringly impressive piece of software.