duckdb / duckdb/duckdb-postgres
Composite Type converted to string when using postgres_query
- Dominant language
- C++
- Stars
- 372
- Forks
- 105
- Avg merge
- 10h 19m
- Merged PRs (30d)
- 18
Description
### What happens?
I try to query a composite type defined as this:
```sql
CREATE TYPE dim.tree_info_type AS
(
id bigint,
ordered_nr bigint,
children_to_nr bigint,
level integer,
parent_ids bigint[]
);
```
using postgres_query:
```python
conn.execute(
""" select * from postgres_query('az_postgres', 'select tree_info from dim.article_group_tree limit 10')"""
)
print(conn.description)
print(conn.fetchall())
```
which gives me:
```
[('tree_info', 'STRING', None, None, None, None, None)]
[('(1,1,233,0,{})',), ('(2,234,672,0,{})',), ('(3,673,1045,0,{})',), ('(4,1046,1081,0,{})',), ('(5,1082,1125,0,{})',), ('(6,1126,1145,0,{})',), ('(7,1146,1216,0,{})',), ('(8,1217,1231,0,{})',), ('(9,1232,1248,0,{})',), ('(10,1249,1252,0,{})',)]
```
It should be a dict, which works if I do the select directly
```
[('tree_info', 'dict', None, None, None, None, None)]
[({'id': 1, 'ordered_nr': 1, 'children_to_nr': 233, 'level': 0, 'parent_ids': []},), ({'id': 2, 'ordered_nr': 234, 'children_to_nr': 672, 'level': 0, 'parent_ids': []},), ({'id': 3, 'ordered_nr': 673, 'children_to_nr': 1045, 'level': 0, 'parent_ids': []},), ({'id': 4, 'ordered_nr': 1046, 'children_to_nr': 1081, 'level': 0, 'parent_ids': []},), ({'id': 5, 'ordered_nr': 1082, 'children_to_nr': 1125, 'level': 0, 'parent_ids': []},), ({'id': 6, 'ordered_nr': 1126, 'children_to_nr': 1145, 'level': 0, 'parent_ids': []},), ({'id': 7, 'ordered_nr': 1146, 'children_to_nr': 1216, 'level': 0, 'parent_ids': []},), ({'id': 8, 'ordered_nr': 1217, 'children_to_nr': 1231, 'level': 0, 'parent_ids': []},), ({'id': 9, 'ordered_nr': 1232, 'children_to_nr': 1248, 'level': 0, 'parent_ids': []},), ({'id': 10, 'ordered_nr': 1249, 'children_to_nr': 1252, 'level': 0, 'parent_ids': []},)
```
### To Reproduce
- Create the type as described
- Create a sample table
- insert some data
- Query it using postgres_query
### OS:
Windows
### PostgreSQL Version:
17.5
### DuckDB Version:
1.3.2
### DuckDB Client:
Python
### Full Name:
Adrian Ehrsam
### Affiliation:
Building Material Suisse
### Have you tried this on the latest `main` branch?
- [x] I agree
### Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?
- [x] I agree
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.