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

Support for converting DuckDB STRUCT type to Postgres composite ROW type #599

Open
JelteF opened this issue Feb 14, 2025 · 4 comments
Open
Labels
types Issues related to type conversions

Comments

@JelteF
Copy link
Collaborator

JelteF commented Feb 14, 2025

Description

DuckDB has anonymous STRUCT types, with named fields. Postgres doesn't have an equivalent type. The best we can probably do is use the ROW type. This is anonymous compound type, but the fields are not named.

Once supported we can un-exclude the STRUCT types from this test:

struct,
struct_of_arrays,

@JelteF JelteF added the types Issues related to type conversions label Feb 14, 2025
@destrex271
Copy link
Contributor

@JelteF picking this up

@destrex271
Copy link
Contributor

is it possible to consider using jsonb for the struct type? There are some similarities in how operations are performed on them while writing sql.

@JelteF
Copy link
Collaborator Author

JelteF commented Feb 27, 2025

Hmm, yeah I think this one is actually more difficult than I thought it was. We'll probably want to create a new Postgres type. This type should be very similar to the duckdb.row type (which was introduced in pg_duckdb 0.3). The main difference is that it should not automatically "star expand". Other than that it can behave the same duckdb.row, i.e. implement the subscripting (aka indexing) operator which returns a duckdb.unresolved_type.

If a query then actually outputs a duckdb.row, only then should a STRUCT type be mapped to postgres ROW type.

@destrex271
Copy link
Contributor

Cool, I'll get started with this then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types Issues related to type conversions
Projects
None yet
Development

No branches or pull requests

2 participants