duckdb / duckdb/pg_duckdb

Support arrays with a fixed length

Open
#602 0 comments 0 reactions 0 assignees View on GitHub
good first issue types
Dominant language
C++
Stars
3.2k
Forks
204
PR merge metrics
No merged PRs in 30d

Description

### Description

DuckDB allows arrays to have a fixed length. But returning those from a query currently throws an error that we don't support the type.
```
select * from duckdb.query($$ select [1, 2]::int[2] $$);
WARNING: 01000: (PGDuckDB/GetPostgresDuckDBType) Could not convert DuckDB type: INTEGER[2] to Postgres type
LOCATION: GetPostgresDuckDBType, pgduckdb_types.cpp:1098
ERROR: XX000: (PGDuckDB/CreatePlan) Cache lookup failed for type 0
LOCATION: CreatePlan, pgduckdb_planner.cpp:76
```

It should be pretty simple to support these by simply converting them to a postgres array type (without a specified length). i.e. convert `INTEGER[2]` to `INTEGER[]` automatically.

Once we do this we should be able to un-exclude a bunch of these lines: https://github.com/duckdb/pg_duckdb/blob/02ebeaec1b42619fab806fc881e67de0821b380d/test/regression/expected/test_all_types.out#L21-L27

Contributor guide

Open the contributing guide

Research direction

Start in pgduckdb_types.cpp around GetPostgresDuckDBType at line 1098, then reproduce the fixed-length array query shown in the issue. Check the excluded lines in test/regression/expected/test_all_types.out around lines 21-27. Done means fixed-length DuckDB arrays are returned as PostgreSQL arrays without the type-conversion error and the relevant expectations can be un-excluded.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.