Skip to content

fix: Store list-typed key columns as varchar in DuckDB#22976

Merged
kodiakhq[bot] merged 4 commits into
mainfrom
fix/duckdb-list-primary-key
Jun 19, 2026
Merged

fix: Store list-typed key columns as varchar in DuckDB#22976
kodiakhq[bot] merged 4 commits into
mainfrom
fix/duckdb-list-primary-key

Conversation

@erezrokah

@erezrokah erezrokah commented Jun 18, 2026

Copy link
Copy Markdown
Member

Store DuckDB key columns (primary key or unique) that map to a LIST type as their string representation, since DuckDB can't build an index on a LIST column and previously failed table creation with "Invalid type for index key".

This surfaced syncing the Azure source into DuckDB: the azure_labservices_skus table has a list-typed locations column marked as part of the primary key.

This is not a breaking change: these tables could never be created before (table creation failed outright), so there is no existing data or schema to migrate.

DuckDB can't build a PRIMARY KEY / UNIQUE index on a LIST column
("Invalid type for index key"), which failed table creation for source
tables with a list-typed key column. Store such columns as their string
representation so the key stays enforceable without losing data.
@erezrokah erezrokah marked this pull request as ready for review June 18, 2026 18:33
@erezrokah erezrokah requested a review from a team as a code owner June 18, 2026 18:33
@erezrokah erezrokah requested review from Copilot and dcelasun June 18, 2026 18:33
@erezrokah erezrokah requested a review from murarustefaan June 18, 2026 18:36
@erezrokah erezrokah added the automerge Automatically merge once required checks pass label Jun 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a DuckDB limitation where PRIMARY KEY / UNIQUE indexes cannot be created on LIST-typed columns by storing key LIST columns (PK/UNIQUE) as VARCHAR containing the list’s string representation. This prevents table creation failures like “Invalid type for index key” while keeping key enforcement.

Changes:

  • Add detection for “key list columns” and map them to varchar in DuckDB DDL.
  • Write key LIST values as strings into Parquet so copied data matches the created DuckDB schema.
  • Update schema normalization and add a regression test for LIST primary keys.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plugins/destination/duckdb/client/write.go Skips list-update workaround for key LIST columns; adds helpers to map key LIST columns to varchar; updates tmp-file schema handling.
plugins/destination/duckdb/client/types.go Adjusts Parquet write schema to emit key LIST columns as Arrow string to match DuckDB varchar.
plugins/destination/duckdb/client/transform.go Serializes LIST arrays to string when the target schema expects string (key LIST columns).
plugins/destination/duckdb/client/migrate.go Normalizes key LIST columns to varchar for diffing and uses new DuckDB type mapping during table creation.
plugins/destination/duckdb/client/client_test.go Adds a test ensuring LIST primary keys migrate and deduplicate correctly with locations stored as VARCHAR.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread plugins/destination/duckdb/client/write.go
Comment thread plugins/destination/duckdb/client/types.go
- reverseTransformArray: decode key list columns (stored as varchar) back
  to LIST instead of panicking on the *array.String.
- containsList: only flag top-level DuckDB LIST columns (struct/map map to
  json and don't need the delete+insert workaround).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread plugins/destination/duckdb/client/write.go
Maps implement arrow.ListLikeType but map to DuckDB json, not a LIST.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@kodiakhq kodiakhq Bot merged commit c642ebc into main Jun 19, 2026
9 checks passed
@kodiakhq kodiakhq Bot deleted the fix/duckdb-list-primary-key branch June 19, 2026 07:53
kodiakhq Bot pushed a commit that referenced this pull request Jun 19, 2026
🤖 I have created a release *beep* *boop*
---


## [6.3.10](plugins-destination-duckdb-v6.3.9...plugins-destination-duckdb-v6.3.10) (2026-06-19)


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.95.3 ([#22946](#22946)) ([b9aac1f](b9aac1f))
* Store list-typed key columns as varchar in DuckDB ([#22976](#22976)) ([c642ebc](c642ebc))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/plugin/destination/duckdb automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants