Skip to content

fix: Uses SQL tables if available for script calls #4785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

dmadisetti
Copy link
Collaborator

Also fixes some lint errors
fixes #4675

Copy link

vercel bot commented May 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
marimo-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 5, 2025 11:15pm

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances SQL execution by allowing the optional inclusion of SQL tables for script calls and resolves some lint errors. Key changes include:

  • Adding tests for script hooks in tests/_sql/test_sql.py.
  • Modifying the wrapped_sql and sql functions to accept an optional "tables" parameter.
  • Updating engine execute signatures across different modules to support the new "tables" parameter.
  • Adapting the frontend Codemirror SQL string generation to include table parameters for DuckDB.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/_sql/test_sql.py Added a new test (test_as_script) that ensures proper error handling for script calls.
marimo/_sql/utils.py Enhanced wrapped_sql to accept a "tables" argument; updated globals handling with eval.
marimo/_sql/sql.py Integrated support for the "tables" parameter in the sql function for DuckDB engines.
marimo/_sql/engines/types.py, sqlalchemy.py, pyiceberg.py, ibis.py, duckdb.py, clickhouse.py Updated execute method signatures to include an optional tables parameter.
frontend/src/core/codemirror/language/sql.ts Modified code generation to include table parameters when using the default engine.
frontend/src/core/codemirror/language/tests/sql.test.ts Added tests to validate that table parameters are correctly formatted in generated code.
frontend/src/core/codemirror/completion/utils.ts Only a copyright comment update.

Co-authored-by: Myles Scolnick <[email protected]>
@Light2Dark
Copy link
Collaborator

Light2Dark commented May 2, 2025

just tested and it feels good! ditto on Myles' comment about conflicting table names, but I usually get errors when trying to define/create tables with the same name.

@dmadisetti
Copy link
Collaborator Author

Actually copilot just created a bug


const end = `\n """${showOutputParam}${engineParam}${tablesParam}\n)`;

// TODO: Ruff-wasm is now more main stream (adopted by jupyter-ruff)
Copy link
Contributor

Choose a reason for hiding this comment

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

this manual formatting is quite easy (and gets reformatted with black in the backend). im not sure this is a TODO we want to do for the extra dependency

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Noticed that the line length varies the behavior (ruff rather fit everything on one line if it can). I think the manual formatting may eventually be more effort than it is worth

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.

Fileformat creates lint errors with sql
3 participants