Skip to content

feat(duckdb): support DuckDB, MotherDuck, and Quack protocol data source discovery - #10557

Draft
erensh27 wants to merge 1 commit into
marimo-team:mainfrom
erensh27:feat/duckdb-quack-protocol
Draft

feat(duckdb): support DuckDB, MotherDuck, and Quack protocol data source discovery#10557
erensh27 wants to merge 1 commit into
marimo-team:mainfrom
erensh27:feat/duckdb-quack-protocol

Conversation

@erensh27

Copy link
Copy Markdown

This pull request was authored by a coding agent.

Summary

Closes #9558

Adds DuckDB datasource discovery to marimo._data.data_source_discovery supporting local databases, MotherDuck (md: protocol), and Quack protocol (quack: / quack://).

Features

  1. Quack Protocol & DuckDB Cloud Discovery:
    • Detects QUACK_TOKEN, QUACK_API_KEY, and QUACK_DATABASE
    • Detects Quack protocol URLs (quack:, quack://) specified in DUCKDB_DATABASE
    • Generates idiomatic snippet con = duckdb.connect(os.environ["QUACK_DATABASE"]) or con = duckdb.connect("quack:")
  2. MotherDuck Discovery:
    • Detects MOTHERDUCK_TOKEN / DUCKDB_MOTHERDUCK_TOKEN
    • Detects MOTHERDUCK_DATABASE
    • Generates con = duckdb.connect(f"md:{os.environ['MOTHERDUCK_DATABASE']}") or con = duckdb.connect("md:")
  3. Local DuckDB File Discovery:
    • Detects local database path from DUCKDB_PATH or DUCKDB_DATABASE
    • Supports DUCKDB_READ_ONLY flag
  4. Secret-Free Frontend Metadata:
    • Only exports variable name references (environment-variable) and non-sensitive metadata to frontend.

Testing

  • Added comprehensive unit tests in tests/_data/data_source_discovery/test_duckdb.py testing all protocols, token variants, and combined discovery.
  • Passed full test suite pytest tests/_data/data_source_discovery/ -v (61/61 passed).

…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
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview Aug 14, 2026 6:26pm

Request Review

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@erensh27

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@erensh27

Copy link
Copy Markdown
Author

recheck

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 duckdb discovery 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] = []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(duckdb): support quack protocol

2 participants