Skip to content
TheChatArchiveThe Chat Archive
gpt-5.6-sol· openaiHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

🐛 Bug ❓: Variable name collision for SQL cells using same table name in different…

  1. 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.

  2. Assistant

    I’ll trace how SQL definitions are represented and grouped, then update the conflict logic and add focused regression tests for qualified, unqualified, ownership, and deletion behavior.

  3. Assistant

    The current registry only keeps the leaf variable’s cell set, so it loses the qualified SQL identity needed to distinguish these definitions. I’m mapping all consumers before changing the return shape described by the interface contract.

  4. Assistant

    The clean separation is: keep definitions[name] as the complete ownership index, and maintain a second per-cell conflict identity (unqualified:name or qualified:catalog.schema.table). This also fixes stale typed ownership during deletion, which would otherwise undermine the requested behavior.

  5. Assistant

    The regression coverage now exercises the reported catalog/schema case, exact-qualified collisions, complete leaf-name ownership, deletion cleanup, and error attribution limited to the genuinely conflicting cells. I’m running the targeted runtime and lint suites now.

  6. Assistant

    Targeted tests pass (69 total). The formatter found only one import-order issue in the new test, now corrected; I’m checking Python typing/lint across the project to catch integration issues beyond those tests.

  7. Assistant

    The project-wide lint stage is currently red on pre-existing repository-wide rules (70 unrelated violations); none point to the changed logic. Its formatter did normalize one touched test file, and the type checker is still running.

  8. Assistant

    The first broader test command referenced a nonexistent conversion-test filename, so pytest correctly collected nothing. I’ve corrected the path and am rerunning the affected runtime, edge, dependency-reporting, conversion, and code-mode suites.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.