Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Composite Type converted to string when using postgres_query

Open
#353 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp, postgresql, python
Domain
databases

Research direction

Reproduce the issue from the Python client with the composite type and postgres_query on PostgreSQL 17.5 and DuckDB 1.3.2, then compare its result metadata and values with a direct select. Trace the composite-result type handling and consider the work complete when postgres_query returns dict values instead of a string representation.

Written by the indexing model from the issue text.

Description

What happens?

I try to query a composite type defined as this:

CREATE TYPE dim.tree_info_type AS
        (
            id bigint,
            ordered_nr bigint,
            children_to_nr bigint,
            level integer,
            parent_ids bigint[]
        );

using postgres_query:

    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?
  • 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?
  • I agree
Dominant language
C++
Stars
372
Forks
107
Avg merge
13h 55m
Merged PRs (30d)
13

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from duckdb/duckdb-postgres

All issues in duckdb/duckdb-postgres

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.