Skip to content

Conversation

@scottynomad
Copy link
Contributor

@scottynomad scottynomad commented Oct 17, 2025

What kind of change does this PR introduce?

Adds support for MotherDuck as a remote server type in the DuckDB fdw.

What is the current behavior?

MotherDuck is not currently supported.

What is the new behavior?

create server md_server
  foreign data wrapper duckdb_wrapper
  options (
    type 'md',
    database 'my_db',
    motherduck_token 'eyJ...cU'
  );
create schema if not exists md_local;
import foreign schema "main" limit to ("table1", "table2") from server md_server into md_local;

or using vault secrets

create server md_server
  foreign data wrapper duckdb_wrapper
  options (
    type 'md',
    database 'my_db',
    vault_motherduck_token 'secret_id'
  );

Additional context

MotherDuck is remote DuckDB instance that gets ATTACHed to the local one so we're able to honor the LIMIT TO / EXCEPT table list arguments to IMPORT FOREIGN SCHEMA by pushing them down to the query agains the remote information_schema.

MotherDuck doesn't use a DuckDB secret block, instead it relies on env vars (not relevant here) or configuration settings. Despite what the docs say, passing those settings as url params to the first argument to ATTACH doesn't seem to work any longer.

The test coverage is limited at the moment because afaik there isn't an emulator for md. One potential improvement would be to also add support for attaching to a remote duckdb file on s3 which would share most of this functionality other than the configuration logic. i.e. https://duckdb.org/docs/stable/guides/network_cloud_storage/duckdb_over_https_or_s3

Happy to update the docs accordingly if this change is workable.

MotherDuck is remote DuckDB instance that gets ATTACHed to the local one so we're able to honor the LIMIT TO / EXCEPT table list arguments to `IMPORT FOREIGN SCHEMA` by pushing them down to the query agains the remote information_schema.

MotherDuck doesn't use a DuckDB secret block, instead it relies on env vars (not relevant here) or configuration settings. Despite what the docs say, passing those settings as url params to the first argument to ATTACH doesn't seem to work any longer.
@burmecia
Copy link
Member

Thanks for the PR! It looks great, can you rectify the code formatting issue reported by the CI?

@scottynomad
Copy link
Contributor Author

Thanks for the PR! It looks great, can you rectify the code formatting issue reported by the CI?

Thanks @burmecia, just pushed that fix.

@burmecia
Copy link
Member

Sorry for the delayed CI run, the clippy seems still not happy, could you take a look again?

@scottynomad
Copy link
Contributor Author

Sorry for the delayed CI run, the clippy seems still not happy, could you take a look again?

You're right @burmecia, sorry I missed that. I just pushed that fix. Also went on a journey to get vault installed locally and tested that the vault-backed config works.

@burmecia burmecia added duckdb enhancement New feature or request labels Oct 25, 2025
@burmecia
Copy link
Member

made some minor changes and wait for #513 to fix CI workflow failure.

@burmecia burmecia merged commit 1267083 into supabase:main Oct 27, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duckdb enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants