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, trace how SQL names are represented, then implement conflict-aware grouping while preserving the existing public variable names and ownership semantics. I’ll run focused tests and broader relevant tests afterward, then review the diff before submission.
- Assistant
The root cause is confirmed: the registry keys SQL definitions by their leaf name, and the current typed-definition check only distinguishes some SQL/Python cases. Two qualified SQL tables therefore enter the same leaf bucket and are reported as a collision. I’ll retain all leaf-name ownership in
definitions, add per-cell qualified identity metadata, and makeget_multiply_definedreturn conflict groups as specified. Qualified identities will conflict when equal; an unqualified definition will conflict with other definitions of that leaf, preserving Python/unqualified behavior. - Assistant
The tuple API requires updating callers that render errors, notebook conversion, code-mode validation, and dependency-graph reporting; those callers now unpack the name while retaining their prior user-facing output. I also fixed cleanup of typed metadata on deletion so qualified ownership and hierarchical matching do not become stale. The project test import is currently blocked by a missing environment dependency (
msgspec), so I’m using compilation and an isolated registry exercise to verify behavior. - Assistant
Verification is complete: the isolated registry test confirms (1) different schemas do not collide, (2) identical qualified names do collide with the exact cell set, (3) deletion removes the conflict, and (4) an unqualified definition still conflicts with qualified definitions. All modified files compile, and
git diff --checkpasses. The full pytest suite could not start because the environment lacksmsgspec; no tests or repository test files were modified. I’ll now submit the reviewed changes.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.