SQL
Enums vs. Strings
DuckDB enums are automatically cast to `VARCHAR` types whenever necessary. This characteristic allows for enum columns to be used in any `VARCHAR` function. In addition, it also allows for comparisons between different enum columns, or an enum and a `VARCHAR` column.  
For example:  
Regexp_matches is a function that takes a VARCHAR, hence current_mood is cast to VARCHAR:  
```sql
SELECT regexp_matches(current_mood, '.*a.*') AS contains_a
FROM person;
```  
| contains_a |
|:-----------|
| true       |
| NULL       |
| true       |
| false      |  
Create a new mood and table:  
```sql
CREATE TYPE new_mood AS ENUM ('happy', 'anxious');
CREATE TABLE person_2 (
name text,
current_mood mood,
future_mood new_mood,
past_mood VARCHAR
);
```  
Since the `current_mood` and `future_mood` columns are constructed on different enum types, DuckDB will cast both enums to strings and perform a string comparison:  
```sql
SELECT *
FROM person_2
WHERE current_mood = future_mood;
```  
When comparing the `past_mood` column (string), DuckDB will cast the `current_mood` enum to `VARCHAR` and perform a string comparison:  
```sql
SELECT *
FROM person_2
WHERE current_mood = past_mood;
```