🐛 Bug ❓: Variable name collision for SQL cells using same table name in different…
- User
🐛 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
-- Cell 1 CREATE TABLE finance.datalake.xx (id INT);-- Cell 2 CREATE TABLE finance.information_layer.xx (id INT);ERROR
This 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
requires-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
Type: Function Name: get_multiply_defined Path: marimo/_runtime/dataflow/definitions.py Input: self Output: list[tuple[Name, set[CellId_t]]] Description: Returns a list of (name, cell_ids) tuples for names that are defined in multiple cells. Uses conflict-aware grouping so that qualified SQL names (e.g., schema.table) with the same leaf name are not considered multiply defined unless they share the exact same qualified name.
- Assistant
I’ll inspect the definition model and its SQL-related tests first, then implement conflict-aware grouping and run focused checks.
- Assistant
The current registry already has partial SQL special-casing during registration, but it loses qualified identity and its return type differs from the requested interface. I’m tracing all callers before changing the data structure so ownership and deletion remain intact.
- Assistant
I found the key invariant:
definitions["xx"]must continue to contain every defining cell for the user-facingxxvariable, while collision detection needs a separate identity map keyed byfinance.datalake.xx,finance.information_layer.xx, or unqualifiedxx. I’m implementing that separation and making unregister clean both ownership and identity indexes. - Assistant
The focused dataflow suite is running now. The new cases cover both sides of the contract: different qualified identities retain both owners without conflict, while an exact qualified-name duplicate reports the precise two-cell conflict group.
- Assistant
The behavioral tests pass (84 passed, 2 optional-dependency skips). The broad lint command surfaced five pre-existing property-docstring violations elsewhere in
graph.py; I’m isolating checks to the changed logic and running the repository’s Python type-check path next. - Assistant
Runtime and edge tests are clean; the targeted type check is still working through the project’s import graph after installing its isolated type-check environment. No code issues have appeared so far.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →