fix: Store list-typed key columns as varchar in DuckDB#22976
Merged
Conversation
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.
There was a problem hiding this comment.
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
varcharin 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.
- 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).
Maps implement arrow.ListLikeType but map to DuckDB json, not a LIST.
stoovon
approved these changes
Jun 19, 2026
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_skustable has a list-typedlocationscolumn 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.