fix sql defs lookup#9754
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Fixes a false multiple-definition error for SQL cells that create tables with the same leaf name in different qualified schemas/catalogs (e.g. finance.datalake.xx vs finance.information_layer.xx). The DefinitionRegistry now decouples its name-lookup index from conflict detection, so qualified SQL definitions are grouped by their fully qualified name when checking for redefinitions, while still being discoverable by leaf name for SQL edge resolution.
Changes:
- Add
definition_conflicts/conflict_nameskeyed on ("sql", qualified_name) for SQL or ("global", name) otherwise;get_multiply_defined()now reports conflicts from this map. - Update
unregister_definitionsto takevariable_data(so it can compute the conflict key and prune typed/conflict tables);delete_cellpassescell.variable_dataaccordingly. - Rewire
validate_graph.check_for_multiple_definitionsandgraph.get_multiply_definedthrough a newget_multiply_defined_conflicts()API; add tests for catalog/schema/qualified/unqualified redefinition scenarios.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| marimo/_runtime/dataflow/definitions.py | Replace definition_types with conflict-key tracking; update register/unregister and multiply-defined logic. |
| marimo/_runtime/dataflow/graph.py | Pass variable_data to unregister; expose get_multiply_defined_conflicts(). |
| marimo/_lint/validate_graph.py | Use the new conflicts API to emit MultipleDefinitionErrors. |
| tests/_runtime/test_dataflow.py | Add tests for same-name diff-schema/catalog, same qualified name, unqualified, and delete-clears-conflict. |
| tests/_lint/test_validate_graph.py | Add lint-level test that qualified SQL names are used for multiple-definition errors. |
There was a problem hiding this comment.
1 issue found across 5 files
Architecture diagram
sequenceDiagram
participant Cell as Cell Registration
participant Registry as DefinitionRegistry
participant DefIndex as definitions dict
participant TypedIndex as typed_definitions dict
participant ConflictIndex as definition_conflicts dict
participant Graph as DirectedGraph
participant Lint as check_for_multiple_definitions
Note over Cell,Lint: SQL Definition Registration with Qualified Name Conflict Resolution
Cell->>Registry: register_definition(name, variable_data, cell_id)
Registry->>Registry: _conflict_key(name, variable)
alt qualified SQL def (e.g. finance.datalake.xx)
Registry->>Registry: conflict_key = ("sql", "finance.datalake.xx")
else unqualified SQL or Python def
Registry->>Registry: conflict_key = ("global", name)
end
Registry->>DefIndex: store name -> cell_id
Registry->>TypedIndex: store (name, kind) -> cell_id
Registry->>ConflictIndex: store conflict_key -> cell_id
Registry->>ConflictIndex: check for duplicate conflict_key
alt duplicate conflict_key found
ConflictIndex-->>Registry: sibling cells with same conflict_key
Registry-->>Cell: return siblings (conflicting cells)
else no duplicate
Registry-->>Cell: return empty set
end
Note over Graph,ConflictIndex: Checking for Multiple Definitions
Graph->>Registry: get_multiply_defined()
Registry->>ConflictIndex: iterate over definition_conflicts
alt len(definers) > 1
ConflictIndex-->>Registry: conflict_key + definers
Registry->>Registry: map conflict_key to Name via conflict_names
Registry-->>Graph: [(name, set of cell_ids)]
else no conflicts
Registry-->>Graph: []
end
Graph->>Lint: get_multiply_defined_conflicts()
Lint->>Lint: build MultipleDefinitionError per conflicting cell
Note over Cell,Registry: Cell Deletion and Cleanup
Graph->>Registry: unregister_definitions(cell_id, variable_data)
loop for each name in variable_data
Registry->>DefIndex: discard cell_id
Registry->>TypedIndex: discard cell_id
Registry->>ConflictIndex: discard cell_id
opt conflict_key has no remaining cells
Registry->>ConflictIndex: delete conflict_key
Registry->>Registry: pop conflict_names
end
opt name has no remaining cells
Registry->>DefIndex: delete name
end
end
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
📝 Summary
Closes #9744
📋 Pre-Review Checklist
✅ Merge Checklist