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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: support duckdb 1.1.0, update globals() for scanning (#2279)
Myles Scolnick9b0045196586
diff --git a/marimo/_sql/sql.py b/marimo/_sql/sql.pyindex 874b0ed61f..303e0bb74e 100644--- a/marimo/_sql/sql.py+++ b/marimo/_sql/sql.py@@ -8,6 +8,10 @@ from marimo._dependencies.dependencies import DependencyManagerfrom marimo._output.rich_help import mddocfrom marimo._plugins.ui._impl import tablefrom marimo._runtime import output+from marimo._runtime.context.types import (+ ContextNotInitializedError,+ get_context,+)def get_default_result_limit() -> Optional[int]:@@ -37,7 +41,22 @@ def sql(import duckdb # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501- relation = duckdb.sql(query=query)+ # In Python globals() are scoped to modules; since this function+ # is in a different module than user code, globals() doesn't return+ # the kernel globals, it just returns this module's global namespace.+ #+ # However, duckdb needs access to the kernel's globals. For this reason,+ # we manually exec duckdb and provide it with the kernel's globals.+ try:+ ctx = get_context()+ except ContextNotInitializedError:+ relation = duckdb.sql(query=query)+ else:+ relation = eval(+ "duckdb.sql(query=query)",+ ctx.globals,+ {"query": query, "duckdb": duckdb},+ )if not relation:return Nonediff --git a/pyproject.toml b/pyproject.tomlindex 3f047ac822..3b61ecaa0b 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -85,7 +85,7 @@ dev = [# For server testing"httpx~=0.27.0",# For SQL- "duckdb~=1.0.0",+ "duckdb~=1.1.0",# For testing mo.ui.chart, dataframes, tables"pandas>=1.5.3","pandas-stubs>=1.5.3.230321",