-
Notifications
You must be signed in to change notification settings - Fork 129
Support for STRUCT type #669
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
src/pgduckdb_types.cpp
Outdated
@@ -250,6 +250,12 @@ ConvertTimeTzDatum(const duckdb::Value &value) { | |||
return TimeTzADTPGetDatum(result); | |||
} | |||
|
|||
inline Datum | |||
ConvertDuckRowDatum(const duckdb::Value &value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really have a separate duckdb.struct
type and not reuse the duckdb.row
type (but you can copy and slightly modify the implementation of duckdb.row
to create this new duckdb.struct
type). We need this for one important reason (and possibly a few other less important ones): When duckdb.row
is part of a select list, we replace it with a *
before sending it to duckdb. We don't want that for this struct type. Apart from that they can basically behave the same, but we need two separate types to make the distinction between a type that is really a multiple columns under the hood (and which thus needs *
expansion) versus a type that actually is a single column with a composite type in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JelteF do we also need to give the ability to create this type from postgres? like -
CREATE TABLE tester(a duckdb.struct);
INSERT INTO TABLE tester(a) VALUES('{a:12, b:12, c:Akshat}');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also correct me if I am wrong but we are handling the star exapnsion in pgduckdb_ddl::DuckdbHandleDDL
, right?
As far as I understood, pgduckdb_target_list_contains_unresolved_type_or_row
function helps us in this decision, right?
src/pgduckdb_ruleutils.cpp
Outdated
@@ -101,6 +106,14 @@ pgduckdb_var_is_duckdb_row(Var *var) { | |||
return pgduckdb_is_duckdb_row(var->vartype); | |||
} | |||
|
|||
bool | |||
pgduckdb_var_is_duckdb_struct(Var *var) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Where is this utility be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for pointing that out! we won't need that for duckdb.struct
. I'll get rid of pgduckdb_var_is_duckdb_struct
and pgduckdb_is_duckdb_struct
functions
Thanks for working on this. I made some relatively small improvements. The major one is to return the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me now
Thanks! |
This introduces a
duckdb.struct
type to postgres which can be used to read theSTRUCT
type in DuckDB.Fixes #599