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
test: avoid false SQL failures with DuckDB 2 (#11356)
Shahmir Varqhaf1358c39e0f3
diff --git a/tests/_sql/test_sql.py b/tests/_sql/test_sql.pyindex 45094b4cee..ce1786d5bd 100644--- a/tests/_sql/test_sql.py+++ b/tests/_sql/test_sql.py@@ -7,7 +7,6 @@ from typing import TYPE_CHECKINGfrom unittest.mock import MagicMock, patchimport pytest-from inline_snapshot import snapshotfrom marimo._config.config import SqlOutputTypefrom marimo._dependencies.dependencies import Dependency, DependencyManager@@ -691,25 +690,14 @@ logical_plan"""Test extract_explain_content with a DuckDB relation."""import duckdb- conn = duckdb.connect(":memory:")- conn.sql("CREATE TABLE t AS SELECT * FROM range(5) tbl(id)")- relation = conn.sql("EXPLAIN SELECT * FROM t")- result = extract_explain_content(relation)-- assert result == snapshot("""\-physical_plan-┌───────────────────────────┐-│ SEQ_SCAN │-│ ──────────────────── │-│ Table: memory.main.t │-│ Type: Sequential Scan │-│ Projections: id │-│ │-│ ~5 rows │-└───────────────────────────┘-""")-- conn.close()+ with duckdb.connect(":memory:") as conn:+ conn.sql("CREATE TABLE t AS SELECT * FROM range(5) tbl(id)")+ query = "EXPLAIN SELECT * FROM t"+ expected = conn.execute(query).fetchone()+ assert expected is not None+ result = extract_explain_content(conn.sql(query))++ assert result == f"{expected[0]}\n{expected[1]}"def test_extract_explain_content_fallback(self):"""Test extract_explain_content fallback for non-DataFrame objects."""diff --git a/tests/_sql/test_sql_parse.py b/tests/_sql/test_sql_parse.pyindex e3ccd95fa8..416fac339e 100644--- a/tests/_sql/test_sql_parse.py+++ b/tests/_sql/test_sql_parse.py@@ -207,14 +207,14 @@ class TestDuckDBInvalidQueries:("SELECT * FROM table WHERE", ["syntax", "error"]),("SELECT * FROM table ORDER", ["syntax", "error"]),("INSERT INTO", ["syntax", "error"]),- ("UPDATE", ["syntax", "error"]),- ("DELETE", ["syntax", "error"]),+ ("UPDATE users SET", ["syntax", "error"]),+ ("DELETE FROM", ["syntax", "error"]),# Unclosed parentheses("SELECT COUNT(*", ["syntax", "error"]),# Unclosed quotes# ("SELECT 'unclosed string", ["syntax", "error"]), # DuckDB does not raise errors for this case# # Invalid function call- ("SELECT COUNT(DISTINCT)", ["syntax", "error"]),+ ("SELECT COUNT(DISTINCT FROM users)", ["syntax", "error"]),# # Malformed CASE statement("SELECT CASE WHEN FROM table", ["syntax", "error"]),# # Incomplete JOIN