Skip to content

fix: DuckLake DuckDB-backed catalog attach incorrectly applies META_TYPE 'sqlite'#3871

Open
Analect wants to merge 4 commits intodlt-hub:develfrom
Analect:fix/3870-ducklake-duckdb-catalog-meta-type
Open

fix: DuckLake DuckDB-backed catalog attach incorrectly applies META_TYPE 'sqlite'#3871
Analect wants to merge 4 commits intodlt-hub:develfrom
Analect:fix/3870-ducklake-duckdb-catalog-meta-type

Conversation

@Analect
Copy link
Copy Markdown

@Analect Analect commented Apr 16, 2026

drivername='duckdb' was handled identically to 'sqlite' in build_attach_statement, adding META_TYPE 'sqlite' / META_JOURNAL_MODE 'WAL' parameters that cause DuckDB-format catalog files to fail with:

Failed to execute query "PRAGMA journal_mode=WAL": file is not a database

Split the combined elif branch so drivername='duckdb' generates a clean attach:

ATTACH IF NOT EXISTS 'ducklake:{path}' AS {name} (DATA_PATH '...')

The DuckLakeCredentials docstring explicitly lists duckdb:///catalog.duckdb as a valid catalog URI, confirming this is a supported use case.

Description

Problem

When using a DuckDB-backed DuckLake catalog (catalog="duckdb:///catalog.duckdb"),
pipeline.run() fails with:

dlt.destinations.exceptions.DestinationConnectionError:
Failed to execute query "PRAGMA journal_mode=WAL": file is not a database

Root cause

build_attach_statement in sql_client.py handled both drivername='sqlite'
and drivername='duckdb' in a single branch, always appending
META_TYPE 'sqlite', META_JOURNAL_MODE 'WAL', META_BUSY_TIMEOUT 1000.
META_TYPE 'sqlite' causes DuckLake to use SQLite operations on the catalog
file. For a DuckDB-format file this hits the SQLite PRAGMA journal_mode=WAL
and raises "file is not a database".

Fix

Split the combined elif into two separate branches. drivername='duckdb'
now generates a clean attach without META_TYPE:

ATTACH IF NOT EXISTS 'ducklake:{path}' AS {name} (DATA_PATH '...')

Tests

Added tests/load/pipeline/test_ducklake_attach.py with unit tests for
build_attach_statement covering both the sqlite and duckdb cases. Tests
can be run without external credentials.

Related Issues

Additional Context

Tests pass without external credentials or a live DuckLake instance:

```
pytest tests/load/pipeline/test_ducklake_attach.py -v

tests/load/pipeline/test_ducklake_attach.py::test_sqlite_catalog_includes_meta_type_sqlite PASSED
tests/load/pipeline/test_ducklake_attach.py::test_duckdb_catalog_excludes_meta_type_sqlite PASSED
tests/load/pipeline/test_ducklake_attach.py::test_duckdb_catalog_attach_format PASSED

3 passed in 1.06s
```

drivername='duckdb' was handled identically to 'sqlite' in
build_attach_statement, adding META_TYPE 'sqlite' / META_JOURNAL_MODE 'WAL'
parameters that cause DuckDB-format catalog files to fail with:

    Failed to execute query "PRAGMA journal_mode=WAL": file is not a database

Split the combined elif branch so drivername='duckdb' generates a clean attach:

    ATTACH IF NOT EXISTS 'ducklake:{path}' AS {name} (DATA_PATH '...')

The DuckLakeCredentials docstring explicitly lists duckdb:///catalog.duckdb
as a valid catalog URI, confirming this is a supported use case.

Fixes dlt-hub#3870
@Analect
Copy link
Copy Markdown
Author

Analect commented Apr 24, 2026

@burnash ... is there anything I need tweaking to have this considered? Thanks.

@rudolfix rudolfix self-assigned this May 5, 2026
@rudolfix rudolfix added the ci from fork Use to trigger CI on a PR (even from a fork) label May 5, 2026
@rudolfix rudolfix added ci from fork Use to trigger CI on a PR (even from a fork) and removed ci from fork Use to trigger CI on a PR (even from a fork) labels May 5, 2026
@rudolfix rudolfix deployed to fork-ci May 5, 2026 21:48 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci from fork Use to trigger CI on a PR (even from a fork)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DuckLake: duckdb:/// catalog URI incorrectly applies META_TYPE 'sqlite', breaking DuckDB-backed catalogs

3 participants