Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

deps: wider duckdb support, wider types check (#7644)

Myles Scolnicke2c4dd26beb0
diff --git a/.github/workflows/test_cli.yaml b/.github/workflows/test_cli.yaml
index b0d155355c..4f48b62af5 100644
--- a/.github/workflows/test_cli.yaml
+++ b/.github/workflows/test_cli.yaml
@@ -139,8 +139,7 @@ jobs:
uv run --no-project pytest -v tests/_cli/test_cli* --maxfail=2
test_examples:
- needs: [changes, build_wheel]
- if: ${{ needs.changes.outputs.cli == 'true' }}
+ needs: [changes]
name: Tests examples and smoke_tests
runs-on: ubuntu-latest
timeout-minutes: 3 # 2024-01-18 avg: 0.3m max: 0.5m
@@ -156,16 +155,6 @@ jobs:
enable-cache: true
python-version: 3.12
- - name: Download wheel
- uses: actions/download-artifact@v4
- with:
- name: testwheel
-
- - name: Install Python deps
- run: |
- uv add pytest pytest-asyncio
- uv pip install marimo*whl
-
- name: Check example quality with marimo check
shell: bash
run: |
diff --git a/marimo/_data/get_datasets.py b/marimo/_data/get_datasets.py
index 9718570244..fc71e408b2 100644
--- a/marimo/_data/get_datasets.py
+++ b/marimo/_data/get_datasets.py
@@ -69,7 +69,7 @@ def _get_data_table(
def has_updates_to_datasource(query: str) -> bool:
- import duckdb # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501
+ import duckdb
try:
statements = duckdb.extract_statements(query.strip())
@@ -77,14 +77,23 @@ def has_updates_to_datasource(query: str) -> bool:
# May not be valid SQL
return False
- return any(
- statement.type == duckdb.StatementType.ATTACH
- or statement.type == duckdb.StatementType.DETACH
- or statement.type == duckdb.StatementType.ALTER
+ # duckdb > 1.4.0 added _STATEMENT suffix to the statement types
+ STATEMENT_TYPES = {
+ "ATTACH_STATEMENT",
+ "ATTACH",
+ "DETACH_STATEMENT",
+ "DETACH",
+ "ALTER_STATEMENT",
+ "ALTER",
# This may catch some false positives for other CREATE statements
- or statement.type == duckdb.StatementType.CREATE
- for statement in statements
- )
+ "CREATE_STATEMENT",
+ "CREATE",
+ }
+
+ for statement in statements:
+ if statement.type.name in STATEMENT_TYPES:
+ return True
+ return False
def execute_duckdb_query(
diff --git a/marimo/_sql/utils.py b/marimo/_sql/utils.py
index 26d453d665..46da4c948b 100644
--- a/marimo/_sql/utils.py
+++ b/marimo/_sql/utils.py
@@ -66,7 +66,7 @@ def try_convert_to_polars(
query: str,
connection: ConnectionOrCursor,
lazy: bool,
-) -> tuple[Optional[pl.DataFrame | pl.LazyFrame], Optional[str]]:
+) -> tuple[Optional[pl.DataFrame | pl.LazyFrame], Optional[Exception]]:
"""Try to convert the query to a polars dataframe.
Returns:
diff --git a/marimo/_tutorials/sql.py b/marimo/_tutorials/sql.py
index bba16e21d9..7fe4c5cf56 100644
--- a/marimo/_tutorials/sql.py
+++ b/marimo/_tutorials/sql.py
@@ -13,7 +13,7 @@
import marimo
-__generated_with = "0.17.4"
+__generated_with = "0.18.4"
app = marimo.App(width="medium")
@@ -196,7 +196,7 @@ def _(has_polars_installed):
import pandas as pd
df = pd.DataFrame(_data)
- return
+ return (df,)
@app.cell(hide_code=True)
@@ -208,7 +208,7 @@ def _(mo):
@app.cell
-def _(mo):
+def _(df, mo):
_df = mo.sql(
f"""
-- This SQL cell is special since we can reference existing dataframes in the global scope as a table in the SQL query. For example, we can reference the `df` dataframe in the global scope, which was defined in another cell using Python.
@@ -247,7 +247,7 @@ def _(mo, string):
@app.cell
-def _(mo, token_prefix):
+def _(df, mo, token_prefix):
result = mo.sql(
f"""
-- Change the dropdown to see the SQL query filter itself!
@@ -387,7 +387,7 @@ def _(mo):
SELECT * from cars;
"""
)
- return (cars,)
+ return
@app.cell(hide_code=True)
@@ -401,7 +401,7 @@ def _(cars, mo):
@app.cell
-def _(cylinders_dropdown, mo, origin_dropdown):
+def _(cars, cylinders_dropdown, mo, origin_dropdown):
filtered_cars = mo.sql(
f"""
SELECT * FROM cars
diff --git a/pixi.lock b/pixi.lock
index e47b6a8152..7683cc9d81 100644
--- a/pixi.lock
+++ b/pixi.lock
@@ -1131,7 +1131,7 @@ packages:
- pypi: ./
name: marimo
version: 0.18.4
- sha256: d0bc9e89edf22435d914a6a9e5eaf079d0610028a0e5c8f35c270cf54d3ae5e1
+ sha256: 75d33a687eaea5b9293810fe11e6cb3d633b7b0ac04ebbe063855dd3f7fc9437
requires_dist:
- click>=8.0,<9
- jedi>=0.18.0
diff --git a/pyproject.toml b/pyproject.toml
index c67eb4895e..48c9810dda 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -176,9 +176,9 @@ dependencies = [
# Types for mypy
"altair>=5.4.0",
"leafmap~=0.39.2",
- "panel~=1.5.3",
- "polars~=1.9.0",
- "duckdb<=1.3.0", # 1.4.0 does not typecheck
+ "panel>=1.5.3",
+ "polars>=1.9.0",
+ "duckdb>=1.0.0",
"narwhals>=2.0.0",
"matplotlib>=3.8.0",
"sqlglot[rs]>=26.2.0",
@@ -191,12 +191,12 @@ dependencies = [
"litellm>=1.70.0",
"python-dotenv>=1.0.1",
"jupytext>=1.17.2",
- "types-Pillow~=10.2.0.20240520",
- "types-Pygments~=2.18.0.20240506",
- "types-psutil~=5.9.5.20240516",
- "types-redis~=4.6.0.20241004",
- "types-Markdown~=3.6.0.20240316",
- "types-PyYAML~=6.0.12.20240808",
+ "types-Pillow>=10.2.0.20240520",
+ "types-Pygments>=2.18.0.20240506",
+ "types-psutil>=5.9.5.20240516",
+ "types-redis>=4.6.0.20241004",
+ "types-Markdown>=3.6.0.20240316",
+ "types-PyYAML>=6.0.12.20240808",
"mcp>=1.0.0",
# zeromq
"pyzmq>=27.1.0",
@@ -252,8 +252,7 @@ extra-dependencies = [
"hvplot~=0.11.3",
# Causes issues installing `shapely` (v2.0.7)
# "geopandas~=1.0.1",
- # FOr testing sql
- "duckdb<=1.3.0", # 1.4.0 does pass
+ "duckdb>=1.0.0",
"ibis-framework[duckdb]>=10.3.0",
# For testing mo.image
"pillow~=10.4.0",