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: sql explain query with newline (#8428)
Myles Scolnick09f9ef17f400
diff --git a/marimo/_sql/utils.py b/marimo/_sql/utils.pyindex 46da4c948b..cf079281a1 100644--- a/marimo/_sql/utils.py+++ b/marimo/_sql/utils.py@@ -190,7 +190,9 @@ def sql_type_to_data_type(type_str: str) -> DataType:def is_explain_query(query: str) -> bool:"""Check if a SQL query is an EXPLAIN query."""- return query.lstrip().lower().startswith("explain ")+ import re++ return bool(re.match(r"\s*explain\s", query, re.IGNORECASE))def wrap_query_with_explain(query: str) -> str:diff --git a/tests/_sql/test_sql.py b/tests/_sql/test_sql.pyindex 562e24b3fe..ddfaa8adb3 100644--- a/tests/_sql/test_sql.py+++ b/tests/_sql/test_sql.py@@ -386,6 +386,10 @@ class TestExplainQueries:assert is_explain_query("EXPLAIN (FORMAT JSON) SELECT 1")assert is_explain_query("EXPLAIN ANALYZE SELECT 1")assert is_explain_query("EXPLAIN QUERY PLAN SELECT 1")+ assert is_explain_query("EXPLAIN\nSELECT 1")+ assert is_explain_query("EXPLAIN\n SELECT 1")+ assert is_explain_query("EXPLAIN\tSELECT 1")+ assert is_explain_query("explain\nSELECT 1")# Test non-EXPLAIN queriesassert not is_explain_query("SELECT 1")