feat(duckdb): support DuckDB, MotherDuck, and Quack protocol data source discovery - #10557
Draft
erensh27 wants to merge 1 commit into
Draft
feat(duckdb): support DuckDB, MotherDuck, and Quack protocol data source discovery#10557erensh27 wants to merge 1 commit into
erensh27 wants to merge 1 commit into
Conversation
…rce discovery - Add DuckDB datasource discovery plugin supporting local database files, MotherDuck (md: protocol), and Quack (quack: / quack:// protocol) - Auto-detects tokens and database specifications from environment variables (MOTHERDUCK_TOKEN, QUACK_TOKEN, QUACK_API_KEY, DUCKDB_DATABASE, DUCKDB_PATH, DUCKDB_READ_ONLY) - Generates clean, idiomatic Python connection snippets - Includes comprehensive unit tests using inline snapshots
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a DuckDB data-source discovery plugin to marimo’s backend discovery system so the UI can suggest secret-free connection snippets for local DuckDB files, MotherDuck (md:), and Quack protocol (quack: / quack://) based on environment variables.
Changes:
- Implement DuckDB/MotherDuck/Quack environment-based discovery in a new
duckdbdiscovery plugin. - Register the new plugin in the default discovery plugin list.
- Add unit tests covering the primary discovery paths and generated code/config metadata.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
marimo/_data/data_source_discovery/plugins/duckdb.py |
New discovery logic for MotherDuck, Quack protocol, and local DuckDB paths (secret-free metadata + code snippets). |
marimo/_data/data_source_discovery/plugins/__init__.py |
Registers DuckDB discovery plugin in the default plugin set. |
tests/_data/data_source_discovery/test_duckdb.py |
Adds test coverage for DuckDB/MotherDuck/Quack discovery outputs and metadata serialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+56
to
+72
|
|
||
|
|
||
| def test_discovers_motherduck_without_database() -> None: | ||
| detected = discover( | ||
| DiscoveryContext( | ||
| environment={ | ||
| "MOTHERDUCK_TOKEN": "secret-md-token", | ||
| } | ||
| ) | ||
| ) | ||
|
|
||
| assert len(detected) == 1 | ||
| assert detected[0].id == "motherduck-environment" | ||
| assert detected[0].display_name == "MotherDuck" | ||
| assert 'con = duckdb.connect("md:")' in detected[0].code | ||
|
|
||
|
|
Comment on lines
+17
to
+21
| DUCKDB_DATABASE_VARIABLES = ( | ||
| "DUCKDB_DATABASE", | ||
| "DUCKDB_PATH", | ||
| "QUACK_DATABASE", | ||
| ) |
Comment on lines
+39
to
+55
| db_name = environment.get("MOTHERDUCK_DATABASE") or environment.get( | ||
| "DUCKDB_DATABASE" | ||
| ) | ||
| if db_name: | ||
| configs.append( | ||
| environment_variable( | ||
| "Database", | ||
| ( | ||
| "MOTHERDUCK_DATABASE" | ||
| if "MOTHERDUCK_DATABASE" in environment | ||
| else "DUCKDB_DATABASE" | ||
| ), | ||
| ) | ||
| ) | ||
| connect_str = f"f\"md:{{os.environ['{configs[-1].value.name}']}}\"" | ||
| else: | ||
| connect_str = '"md:"' |
Comment on lines
+24
to
+27
| def discover(context: DiscoveryContext) -> list[DetectedDataSource]: | ||
| environment = context.environment | ||
| detected: list[DetectedDataSource] = [] | ||
|
|
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.
This pull request was authored by a coding agent.
Summary
Closes #9558
Adds DuckDB datasource discovery to
marimo._data.data_source_discoverysupporting local databases, MotherDuck (md:protocol), and Quack protocol (quack:/quack://).Features
QUACK_TOKEN,QUACK_API_KEY, andQUACK_DATABASEquack:,quack://) specified inDUCKDB_DATABASEcon = duckdb.connect(os.environ["QUACK_DATABASE"])orcon = duckdb.connect("quack:")MOTHERDUCK_TOKEN/DUCKDB_MOTHERDUCK_TOKENMOTHERDUCK_DATABASEcon = duckdb.connect(f"md:{os.environ['MOTHERDUCK_DATABASE']}")orcon = duckdb.connect("md:")DUCKDB_PATHorDUCKDB_DATABASEDUCKDB_READ_ONLYflagenvironment-variable) and non-sensitive metadata to frontend.Testing
tests/_data/data_source_discovery/test_duckdb.pytesting all protocols, token variants, and combined discovery.pytest tests/_data/data_source_discovery/ -v(61/61 passed).