Skip to content

update default duckdb mo.sql deps#9599

Merged
Light2Dark merged 6 commits into
mainfrom
sham/refactor-engine-output-format
May 20, 2026
Merged

update default duckdb mo.sql deps#9599
Light2Dark merged 6 commits into
mainfrom
sham/refactor-engine-output-format

Conversation

@Light2Dark

@Light2Dark Light2Dark commented May 19, 2026

Copy link
Copy Markdown
Member

📝 Summary

When you run mo.sql with duckdb from a fresh engine, it prompts you to install duckdb, and sqlglot, and then after running, prompts to install polars/pandas.

This now gets you to install all 3 packages from the start.
image

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.
@vercel

vercel Bot commented May 19, 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, Comment May 19, 2026 6:36am

Request Review

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 4 files

Architecture diagram
sequenceDiagram
    participant User
    participant mo_sql as mo.sql()
    participant DepManager as DependencyManager
    participant Config as runtime config
    participant DuckDB as DuckDB engine
    
    Note over User,DuckDB: NEW: Bundled dependency resolution
    
    User->>mo_sql: sql(query)
    mo_sql->>Config: get_configured_sql_output_format()
    Config-->>mo_sql: "auto" | "pandas" | "polars" | "lazy-polars" | "native"
    
    mo_sql->>mo_sql: _default_duckdb_deps()
    Note over mo_sql: Always require duckdb + sqlglot
    
    alt sql_output == "auto"
        alt polars or pandas already installed
            mo_sql->>mo_sql: Skip dataframe library
        else neither installed
            mo_sql->>mo_sql: Add polars[pyarrow]
        end
    else sql_output == "pandas"
        mo_sql->>mo_sql: Add pandas
    else sql_output == "polars" or "lazy-polars"
        mo_sql->>mo_sql: Add polars[pyarrow]
    else sql_output == "native"
        mo_sql->>mo_sql: No dataframe library needed
    end
    
    mo_sql->>DepManager: require_many(bundled_deps)
    alt All deps available
        DepManager-->>mo_sql: OK
        mo_sql->>DuckDB: DuckDBEngine(connection=None)
        DuckDB-->>mo_sql: Execute query
        mo_sql-->>User: Result (DataFrame/Relation)
    else Missing deps
        DepManager-->>mo_sql: ManyModulesNotFoundError
        Note over DepManager: Single error listing all missing packages
        mo_sql-->>User: Installation prompt once
    end
Loading

Re-trigger cubic

@Light2Dark Light2Dark added the enhancement New feature or request label May 19, 2026

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

When mo.sql(...) is called with the default DuckDB engine, the previous code only required duckdb + sqlglot upfront and later triggered a second prompt to install a dataframe library (polars/pandas). This PR bundles the dataframe library into the initial dependency check based on the configured sql_output format so users get a single install prompt.

Changes:

  • Added _resolve_default_duckdb_deps in marimo/_sql/sql.py to compute the full default dep list based on SqlOutputType, and use it in sql().
  • Extracted get_configured_sql_output_format() helper into marimo/_sql/utils.py and reused it in marimo/_sql/engines/types.py.
  • Added unit and end-to-end tests, and patched get_configured_sql_output_format in test_get_engines.py to avoid triggering the new dep-bundling.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
marimo/_sql/sql.py Adds dep-resolution helpers and uses them in sql() to prompt for all needed packages at once.
marimo/_sql/utils.py New get_configured_sql_output_format() shared helper.
marimo/_sql/engines/types.py Uses the new shared helper instead of inlining context lookup.
tests/_sql/test_sql.py New tests for _resolve_default_duckdb_deps and end-to-end bundled error.
tests/_sql/test_get_engines.py Patches get_configured_sql_output_format to "native" to skip dataframe-lib check.
@Light2Dark Light2Dark changed the title update default duckdb deps May 19, 2026
@mscolnick

Copy link
Copy Markdown
Contributor

nice, this is a great improvement

@Light2Dark Light2Dark merged commit edbb526 into main May 20, 2026
52 checks passed
@Light2Dark Light2Dark deleted the sham/refactor-engine-output-format branch May 20, 2026 01:41
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.7-dev58

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

Labels

enhancement New feature or request

3 participants