Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek/deepseek-v4-pro· deepseekHugging 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. DeepSeek Assistant

    Let me start by understanding the repository structure and the issue. The problem is about SQL cells in marimo with DuckDB where tables with the same name but in different schemas are considered as variable name collisions. The fix should be in marimo/_runtime/dataflow/definitions.py, specifically in the get_multiply_defined method.

    Let me first explore the repository structure and find the relevant file

  3. DeepSeek Assistant

    Let me find the specific file mentioned in the issue.

  4. DeepSeek Assistant

    Let me open and examine this file.

  5. DeepSeek Assistant

    Let me see the rest of the file

  6. DeepSeek Assistant

    Let me understand the SQL visitor and VariableData structure to see how qualified names are

  7. DeepSeek Assistant

    Let me also look at the VariableData definition.

  8. DeepSeek Assistant

    Let me look at the VariableData class.

  9. DeepSeek Assistant

    Let me open the file properly.

  10. DeepSeek Assistant

    Now let me look at the SQL visitor to understand how qualified names

  11. DeepSeek Assistant

    Let me search for where qualified_name is set in the SQL visitor.

  12. DeepSeek Assistant

    Let me look around line

  13. DeepSeek Assistant

    Let me just view that area.

  14. DeepSeek Assistant

    Let me find where SQL CREATE TABLE/VIEW definitions are registered in the visitor.

  15. DeepSeek Assistant

    Let me look at the SQL definition registration in the visitor more

  16. DeepSeek Assistant

    Let me look at the _define method and how definitions flow into the registry.

  17. DeepSeek Assistant

    Let me find how register_definition is called and how cell definitions are collected

  18. DeepSeek Assistant

    Let me look at how register_definition is called in graph.py

  19. DeepSeek Assistant

    Let me look at how get_defining_cells and get_multiply_defined are used

  20. DeepSeek Assistant

    Let me look at the graph.py code and the key usage sites

  21. DeepSeek Assistant

    Let me just open graph.py at the right line.

  22. DeepSeek Assistant

    Let me look at the code_mode context code where multiply_defined is

  23. DeepSeek Assistant

    Let me look at the app.py code

  24. DeepSeek Assistant

    Let me find the tests for the definitions module

  25. DeepSeek Assistant

    Let me look at the edges.py to understand how SQL definitions are

  26. DeepSeek Assistant

    Let me just view the edges.py relevant sections.

  27. DeepSeek Assistant

    Let me understand all callers of get_multiply_defined and their expectations

  28. DeepSeek Assistant

    Now I have a thorough understanding of the issue. Let me now implement the fix. The strategy:

    1. Add a _conflict_groups field to track qualified names for conflict detection
    2. Update register_definition to populate it
    3. Update unregister_definitions to clean it up
    4. Update get_multiply_defined to use conflict-aware grouping

    Let me write

  29. DeepSeek Assistant

    Now let me implement the fix. I'll edit the DefinitionRegistry class

  30. DeepSeek Assistant

    Let me verify the full

  31. DeepSeek Assistant

    Let me check how cell.defs is set to understand what names are passed to unregister_definitions.

  32. DeepSeek Assistant

    Let me find how cell.defs is populated

  33. DeepSeek Assistant

    Let me search more broadly

  34. DeepSeek Assistant

    Let me find CellImpl

  35. DeepSeek Assistant

    Let me look at CellImpl's defs attribute

  36. DeepSeek Assistant

    Let me find where CellImpl is instantiated and defs is set

  37. DeepSeek Assistant

    Let me look at the compiler code where defs is set

  38. DeepSeek Assistant

    Let me find how nonlocals is populated

  39. DeepSeek Assistant

    Let me check the visitor's def

  40. DeepSeek Assistant

    Now let me run the existing tests related to definitions and multiply-defined to make sure I haven't broken anything.

  41. DeepSeek Assistant

    Let me write a small test script to validate my changes and run it directly

  42. DeepSeek Assistant

    Let me try running the test differently by avoiding the full marimo import chain

  43. DeepSeek Assistant

    Let me install the missing dependency

  44. DeepSeek Assistant

    Now let me try running the test again

  45. DeepSeek Assistant

    Let me try a different approach to test - use -c with specific path manipulation to avoid the full

  46. DeepSeek Assistant

    Let me install the required dependencies

  47. DeepSeek Assistant

    Now let me run the

  48. DeepSeek Assistant

    All tests pass. Now let me run the existing test suite for the relevant

  49. DeepSeek Assistant

    Let me run a broader test to check for breakage - looking for test files related to graph, definitions, or app

  50. DeepSeek Assistant

    Let me check the specific failing

  51. DeepSeek Assistant

    That's a test environment issue (missing async plugin). Let me run tests that are more relevant to definitions and multiply-defined

  52. DeepSeek Assistant

    Let me check if these failures are pre-existing by reverting my change

  53. DeepSeek Assistant

    Same results - pre-existing failures. Let me restore my changes

  54. DeepSeek Assistant

    Let me find and run tests specifically related to multiple

  55. DeepSeek Assistant

    Let me run the app tests specifically related to multiply defined variables

  56. DeepSeek Assistant

    Let me look at this

  57. DeepSeek Assistant

    Let me check if this test was already failing before my changes

  58. DeepSeek Assistant

    Pre-existing failure. Let me run the passing multiply/redefin

  59. DeepSeek Assistant

    The 4 non-async tests pass. Let me look at test_multiple_definitions to understand what it tests

  60. DeepSeek Assistant

    Let me also check the convert tests

  61. DeepSeek Assistant

    All convert tests pass. Let me also check the lint

  62. DeepSeek Assistant

    Let me check if those failures are

  63. DeepSeek Assistant

    Let me check the failing lint

  64. DeepSeek Assistant

    Let me look at the test_multiple_definitions

  65. DeepSeek Assistant

    Let me look at these

  66. DeepSeek Assistant

    Let me check for SQL-specific tests related to definitions

  67. DeepSeek Assistant

    Let me look at the dataflow tests

  68. DeepSeek Assistant

    Let me see the full context

  69. DeepSeek Assistant

    Let me run the dataflow tests to make sure they

  70. DeepSeek Assistant

    Let me see the full output

  71. DeepSeek Assistant

    Let me improve the unregister_definitions to ensure _qualified_defs is always cleaned up, even when a name is not in self.definitions (edge case for SQL with qualified names)

  72. DeepSeek Assistant

    I see there's duplicate code. Let me view the full file to

  73. DeepSeek Assistant

    I see the duplicate. Let me fix the

  74. DeepSeek Assistant

    Good, the file is now clean. Let me rerun the tests to verify everything

  75. DeepSeek Assistant

    All tests pass. Let me also run the existing test suite one

  76. DeepSeek Assistant

    Let me run the graph validation

  77. DeepSeek Assistant

    All graph validation tests pass. Let me now verify the final file is correct

  78. DeepSeek Assistant

    Let me run one final comprehensive set of tests to validate

  79. DeepSeek Assistant

    Let me verify the two failures are pre-existing

  80. DeepSeek Assistant

    Both failures are pre-existing. Let me verify my

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