Skip to content

Commit e2c4dd2

Browse files
authored
deps: wider duckdb support, wider types check (#7644)
This fixes some utils to support duckdb `>1.4.0`
1 parent b3abd35 commit e2c4dd2

File tree

6 files changed

+36
-39
lines changed

6 files changed

+36
-39
lines changed

.github/workflows/test_cli.yaml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ jobs:
139139
uv run --no-project pytest -v tests/_cli/test_cli* --maxfail=2
140140
141141
test_examples:
142-
needs: [changes, build_wheel]
143-
if: ${{ needs.changes.outputs.cli == 'true' }}
142+
needs: [changes]
144143
name: Tests examples and smoke_tests
145144
runs-on: ubuntu-latest
146145
timeout-minutes: 3 # 2024-01-18 avg: 0.3m max: 0.5m
@@ -156,16 +155,6 @@ jobs:
156155
enable-cache: true
157156
python-version: 3.12
158157

159-
- name: Download wheel
160-
uses: actions/download-artifact@v4
161-
with:
162-
name: testwheel
163-
164-
- name: Install Python deps
165-
run: |
166-
uv add pytest pytest-asyncio
167-
uv pip install marimo*whl
168-
169158
- name: Check example quality with marimo check
170159
shell: bash
171160
run: |

marimo/_data/get_datasets.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,31 @@ def _get_data_table(
6969

7070

7171
def has_updates_to_datasource(query: str) -> bool:
72-
import duckdb # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501
72+
import duckdb
7373

7474
try:
7575
statements = duckdb.extract_statements(query.strip())
7676
except Exception:
7777
# May not be valid SQL
7878
return False
7979

80-
return any(
81-
statement.type == duckdb.StatementType.ATTACH
82-
or statement.type == duckdb.StatementType.DETACH
83-
or statement.type == duckdb.StatementType.ALTER
80+
# duckdb > 1.4.0 added _STATEMENT suffix to the statement types
81+
STATEMENT_TYPES = {
82+
"ATTACH_STATEMENT",
83+
"ATTACH",
84+
"DETACH_STATEMENT",
85+
"DETACH",
86+
"ALTER_STATEMENT",
87+
"ALTER",
8488
# This may catch some false positives for other CREATE statements
85-
or statement.type == duckdb.StatementType.CREATE
86-
for statement in statements
87-
)
89+
"CREATE_STATEMENT",
90+
"CREATE",
91+
}
92+
93+
for statement in statements:
94+
if statement.type.name in STATEMENT_TYPES:
95+
return True
96+
return False
8897

8998

9099
def execute_duckdb_query(

marimo/_sql/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def try_convert_to_polars(
6666
query: str,
6767
connection: ConnectionOrCursor,
6868
lazy: bool,
69-
) -> tuple[Optional[pl.DataFrame | pl.LazyFrame], Optional[str]]:
69+
) -> tuple[Optional[pl.DataFrame | pl.LazyFrame], Optional[Exception]]:
7070
"""Try to convert the query to a polars dataframe.
7171
7272
Returns:

marimo/_tutorials/sql.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
import marimo
1515

16-
__generated_with = "0.17.4"
16+
__generated_with = "0.18.4"
1717
app = marimo.App(width="medium")
1818

1919

@@ -196,7 +196,7 @@ def generate_random_numbers(mean, std_dev, num_samples):
196196
import pandas as pd
197197

198198
df = pd.DataFrame(_data)
199-
return
199+
return (df,)
200200

201201

202202
@app.cell(hide_code=True)
@@ -208,7 +208,7 @@ def _(mo):
208208

209209

210210
@app.cell
211-
def _(mo):
211+
def _(df, mo):
212212
_df = mo.sql(
213213
f"""
214214
-- 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):
247247

248248

249249
@app.cell
250-
def _(mo, token_prefix):
250+
def _(df, mo, token_prefix):
251251
result = mo.sql(
252252
f"""
253253
-- Change the dropdown to see the SQL query filter itself!
@@ -387,7 +387,7 @@ def _(mo):
387387
SELECT * from cars;
388388
"""
389389
)
390-
return (cars,)
390+
return
391391

392392

393393
@app.cell(hide_code=True)
@@ -401,7 +401,7 @@ def _(cars, mo):
401401

402402

403403
@app.cell
404-
def _(cylinders_dropdown, mo, origin_dropdown):
404+
def _(cars, cylinders_dropdown, mo, origin_dropdown):
405405
filtered_cars = mo.sql(
406406
f"""
407407
SELECT * FROM cars

pixi.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ dependencies = [
176176
# Types for mypy
177177
"altair>=5.4.0",
178178
"leafmap~=0.39.2",
179-
"panel~=1.5.3",
180-
"polars~=1.9.0",
181-
"duckdb<=1.3.0", # 1.4.0 does not typecheck
179+
"panel>=1.5.3",
180+
"polars>=1.9.0",
181+
"duckdb>=1.0.0",
182182
"narwhals>=2.0.0",
183183
"matplotlib>=3.8.0",
184184
"sqlglot[rs]>=26.2.0",
@@ -191,12 +191,12 @@ dependencies = [
191191
"litellm>=1.70.0",
192192
"python-dotenv>=1.0.1",
193193
"jupytext>=1.17.2",
194-
"types-Pillow~=10.2.0.20240520",
195-
"types-Pygments~=2.18.0.20240506",
196-
"types-psutil~=5.9.5.20240516",
197-
"types-redis~=4.6.0.20241004",
198-
"types-Markdown~=3.6.0.20240316",
199-
"types-PyYAML~=6.0.12.20240808",
194+
"types-Pillow>=10.2.0.20240520",
195+
"types-Pygments>=2.18.0.20240506",
196+
"types-psutil>=5.9.5.20240516",
197+
"types-redis>=4.6.0.20241004",
198+
"types-Markdown>=3.6.0.20240316",
199+
"types-PyYAML>=6.0.12.20240808",
200200
"mcp>=1.0.0",
201201
# zeromq
202202
"pyzmq>=27.1.0",
@@ -252,8 +252,7 @@ extra-dependencies = [
252252
"hvplot~=0.11.3",
253253
# Causes issues installing `shapely` (v2.0.7)
254254
# "geopandas~=1.0.1",
255-
# FOr testing sql
256-
"duckdb<=1.3.0", # 1.4.0 does pass
255+
"duckdb>=1.0.0",
257256
"ibis-framework[duckdb]>=10.3.0",
258257
# For testing mo.image
259258
"pillow~=10.4.0",

0 commit comments

Comments
 (0)