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
Let me first reproduce the issue:
Assistant
Now let me look at all the callers of
get_multiply_defined:Assistant
Now let me implement the fix. First, update
DefinitionRegistry:Assistant
Now update
register_definition,unregister_definitions, andget_multiply_defined:Assistant
There's a stray
>>> REPLACEline at 123; remove it:Assistant
I accidentally left stray
>>> REPLACEmarkers (lines 155 and 232). Remove them:Assistant
The fix works. Now test edge cases:
Assistant
All edge cases pass. Now run the relevant test suites:
Assistant
These two failures are purely due to the return-format change mandated by the interface contract (
["t1"]→[("t1", {"0","1"})]); detection semantics are unchanged. Run other affected suites:Assistant
The
_code_modefailures are pre-existing (same 10 fail without my changes). Let me find the edges test path:Assistant
Run broader test suites to be safe:
Assistant
Pre-existing failure too. Now let's do an end-to-end kernel-level test simulating the actual issue:
Assistant
Verify the first e2e test actually fails without the fix:
Assistant
Removed the temp test. Now check code quality tools on the modified files:
Assistant
All callers updated. Let me review the final diff:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.