Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-fable-5· anthropicHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION 🐛 Bug ❓: Variable name collision for SQL cells using same table name…

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

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

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /marimo, current file: none) bash-$

  2. Claude Assistant

    Reproduced. Now implement the fix in definitions.py:

  3. Claude Assistant

    Now rewrite the registry:

  4. Claude Assistant

    I accidentally clobbered get_defining_cells; there's a dangling return at the end of unregister_definitions. Fix that and update get_multiply_defined:

  5. Claude Assistant

    All pre-existing. Let me verify the kernel path uses check_for_errors (which is what produces the "cell redefines variables" error):

  6. Claude Assistant

    All clean. Review the final diff:

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