ISSUE DESCRIPTION 🐛 Bug ❓: Variable name collision for SQL cells using same table name…
- User
ISSUE DESCRIPTION
🐛 Bug ❓: Variable name collision for SQL cells using same table name in different schemas
Discussed in https://github.com/marimo-team/marimo/discussions/9734
Originally posted by EED85 May 31, 2026
Description
When using multiple SQL cells in marimo with DuckDB, creating tables with the same name in different schemas leads to a variable redefinition error.
Although the tables are fully qualified and valid in DuckDB, marimo raises an error due to internal variable name collisions.
Minimal Reproducible Example
sql-- Cell 1 CREATE TABLE finance.datalake.xx (id INT);sql-- Cell 2 CREATE TABLE finance.information_layer.xx (id INT);ERROR
codeThis cell wasn't run because it has errors This cell redefines variables from other cells. 'xx' was also defined by: dl Fix: Wrap in a function Why can't I redefine variables?Expected Behavior
Since the tables are created in different schemas, both statements should execute without conflict:
Environment
coderequires-python = ">=3.13" dependencies = [ "duckdb", "ipykernel>=7.2.0", "marimo>=0.23.8", "pandas>=3.0.3", "plotly>=6.7.0", "polars>=1.41.2", "pyarrow>=24.0.0", "pydantic-ai>=1.104.0", "ruff>=0.15.15", "sqlglot<30", "tabulate>=0.10.0", ]That is my opinion. What is the marimo way, to handle this?
Best Eric
Evaluation contract
Track SQL definitions by their complete qualified identity. Tables with the same leaf name in different schemas or catalogs are not multiply defined; the same fully qualified name, or the same unqualified name, still is. Preserve the user-facing table variable, defining-cell ownership, deletion behavior, and conflict reporting for genuine collisions.
Interface
- Assistant
I’ll inspect the dataflow definition logic and its tests, then trace how SQL-qualified names are represented. I’ll implement the smallest conflict-aware change that preserves user-facing names and ownership semantics, run focused tests (and a reproduction if practical), review the diff, and submit only after verification.
- Assistant
The existing registry already stores leaf names as the public variable keys, but its duplicate check treats a second same-kind SQL definition as a conflict without retaining the qualified identity. I’ll add per-name identity grouping (
Nonefor unqualified/Python, exact qualified SQL text otherwise), makeget_multiply_definedreturn the contract’s(name, cell_ids)tuples, and update the few callers to consume that richer result while leavingdefinitionsand typed lookup ownership intact. - Assistant
The focused test command is currently blocked by a missing repository dependency (
msgspec), not by test failures. I also noticed the tuple output is specified forDefinitionRegistry, whileDirectedGraphhas an established public name-only API used by existing tests and callers. I’ll preserve that graph-level API by adapting tuples there, avoiding an unnecessary downstream interface break. - Assistant
The direct standalone check hit an artifact of
importlibsetup (the temporary module was not registered insys.modules), rather than application code. I’ll rerun it correctly, then perform final syntax/diff checks. The implementation now also fixes stale typed/qualified ownership records when one of several defining cells is deleted, which is important for deletion behavior.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.