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
datasource parsing fixes (#1815)
Myles Scolnicka102e81b9d79
diff --git a/marimo/_data/get_datasets.py b/marimo/_data/get_datasets.pyindex 69e4d77075..74dc5c5ecd 100644--- a/marimo/_data/get_datasets.py+++ b/marimo/_data/get_datasets.py@@ -58,7 +58,7 @@ def has_updates_to_datasource(query: str) -> bool:import duckdb # type: ignore[import-not-found,import-untyped,unused-ignore] # noqa: E501try:- statements = duckdb.extract_statements(query)+ statements = duckdb.extract_statements(query.strip())except Exception:# May not be valid SQLreturn Falsediff --git a/marimo/_data/sql_visitor.py b/marimo/_data/sql_visitor.pyindex dc2c79fdef..b85794a272 100644--- a/marimo/_data/sql_visitor.py+++ b/marimo/_data/sql_visitor.py@@ -62,4 +62,6 @@ def normalize_sql_f_string(node: ast.JoinedStr) -> str:# Just add '_' as a placeholder for {...} expressionsreturn "'_'"- return "".join(print_part(part) for part in node.values)+ result = "".join(print_part(part) for part in node.values)+ # remove any double '' created by the f-string+ return result.replace("''", "'")diff --git a/tests/_ast/test_visitor.py b/tests/_ast/test_visitor.pyindex 9f110a2032..17bae18b94 100644--- a/tests/_ast/test_visitor.py+++ b/tests/_ast/test_visitor.py@@ -933,6 +933,14 @@ def test_print_f_string() -> None:== "select * from cars where name = '_'")+ joined_str = ast.parse(+ "f'select * from \\'{table}\\' where name = {name}'"+ )+ assert (+ normalize_sql_f_string(joined_str.body[0].value) # type: ignore+ == "select * from '_' where name = '_'"+ )+@pytest.mark.skipif(not HAS_DEPS, reason="Requires duckdb")def test_sql_empty_statement() -> None: