Skip to content

Conversation

LindsayWray
Copy link

@LindsayWray LindsayWray commented Nov 10, 2022

This pr addresses issue #5174 and offers an alternative solution.

@Mause suggested to output an additional field in the underlying table (duckdb_types) instead, which the pg_... view consumes to provide a postgres compatible interface and therefore compatible with SQLAlchemy. So I’ve added the enum type to duckdb_types.

image

14 nov. additions:
The pg_enum view now shows the metadata of enum types similar to Postgres. To get the enum data for this view, I have added an extra column to the duckdb_types table containing the possible values of each enum type.
Some small changes in the format_pg_type function and pg_type view were also required to make this functionality resemble the Postgres results as much as possible.

@LindsayWray LindsayWray requested a review from pdet November 11, 2022 06:15
Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Looks good. Some comments:

Copy link
Contributor

@pdet pdet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Lindsay, many thanks for the PR, it looks great!

Out of curiosity, I see that 'ENUM' becomes an invalid name for an enum, is it only on caps, or 'enum'/'EnUm' are also now invalid?

(I don't even remember if we are case sensitive for enum types although I implemented that (: )

@LindsayWray
Copy link
Author

Hey Lindsay, many thanks for the PR, it looks great!

Out of curiosity, I see that 'ENUM' becomes an invalid name for an enum, is it only on caps, or 'enum'/'EnUm' are also now invalid?

(I don't even remember if we are case sensitive for enum types although I implemented that (: )

it's case insensitive, enum has been added to the catalog and is now like a reserved typename

@Mytherin Mytherin changed the base branch from master to feature November 14, 2022 17:24
Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! Looks great.

@Mytherin Mytherin merged commit 286b243 into duckdb:feature Nov 15, 2022
@cpcloud
Copy link
Contributor

cpcloud commented Nov 15, 2022

cc @saulpw, looks like we can properly support this in ibis now!

@Mause
Copy link
Member

Mause commented Nov 16, 2022

Looking forward to testing this 😁

@Mause
Copy link
Member

Mause commented Nov 18, 2022

Doesn't look like this is working as expected quite just yet, I'm looking into it

@Mause
Copy link
Member

Mause commented Nov 18, 2022

Looks like duckdb_columns() might not properly handle user defined types?

output.SetValue(10, index, Value::BIGINT(int(type.id())));
vs
int64_t oid;
if (type_entry->internal) {
oid = int64_t(type.id());
} else {
oid = type_entry->oid;
}
Value oid_val;
if (data.oids.find(oid) == data.oids.end()) {
data.oids.insert(oid);
oid_val = Value::BIGINT(oid);
} else {
oid_val = Value();
}
output.SetValue(2, count, oid_val);

@LindsayWray
Copy link
Author

Looks like duckdb_columns() might not properly handle user defined types?

I suggest to make this into a separate issue, because I suspect more of these system tables will require similar additions to fully support enums.

@Mause
Copy link
Member

Mause commented Nov 21, 2022

Looks like duckdb_columns() might not properly handle user defined types?

I suggest to make this into a separate issue, because I suspect more of these system tables will require similar additions to fully support enums.

Sounds likely yes

@LindsayWray LindsayWray deleted the enum_type_not_by_name branch November 28, 2022 09:22
hawkfish pushed a commit to hawkfish/duckdb that referenced this pull request Mar 15, 2023
Rewrite the pattern LIST(x ORDER BY x <ordering>) as LIST_SORT(LIST(x), <ordering>).
This reduces the included benchmark run time from 23.5s to 4.32s.
hawkfish pushed a commit to hawkfish/duckdb that referenced this pull request Mar 15, 2023
Add missing include for tidy.
hawkfish pushed a commit to hawkfish/duckdb that referenced this pull request Mar 20, 2023
Correct benchmark description.
hawkfish pushed a commit to hawkfish/duckdb that referenced this pull request Mar 20, 2023
Add more strings to EnumSerializer so LIST_SORT can use it for parsing.
Mytherin added a commit that referenced this pull request Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants