Version: 0.0.192
NodeRevision.cube_elements is a list-backed many-to-many over the cube table, whose PK is (cube_id, cube_element_id). When a cube references the same dimension column under more than one role, both roles resolve to the same Column, so the element list gets a duplicate and flush fails:
(psycopg.errors.UniqueViolation) duplicate key value violates unique constraint "pk_cube"
DETAIL: Key (cube_id, cube_element_id)=(...) already exists.
Repro: create/deploy a cube whose dimensions include store.day[open_day] and store.day[close_day] — the same physical store.day column under two roles. The create (or the whole deployment transaction) rolls back.
Cause: datajunction_server/internal/deployment/orchestrator.py:2677 (and datajunction_server/internal/nodes.py:679) set cube_elements=metric_columns + dimension_columns with no dedup; the role is stripped when resolving the physical column at orchestrator.py:2353-2369, so a repeated-role dimension appends the same Column twice.
Fix: dedup preserving order, e.g. cube_elements=list(dict.fromkeys(metric_columns + dimension_columns)), in both paths; add a regression test for
Version: 0.0.192
NodeRevision.cube_elementsis a list-backed many-to-many over thecubetable, whose PK is(cube_id, cube_element_id). When a cube references the same dimension column under more than one role, both roles resolve to the sameColumn, so the element list gets a duplicate and flush fails:Repro: create/deploy a cube whose dimensions include
store.day[open_day]andstore.day[close_day]— the same physicalstore.daycolumn under two roles. The create (or the whole deployment transaction) rolls back.Cause:
datajunction_server/internal/deployment/orchestrator.py:2677(anddatajunction_server/internal/nodes.py:679) setcube_elements=metric_columns + dimension_columnswith no dedup; the role is stripped when resolving the physical column atorchestrator.py:2353-2369, so a repeated-role dimension appends the sameColumntwice.Fix: dedup preserving order, e.g.
cube_elements=list(dict.fromkeys(metric_columns + dimension_columns)), in both paths; add a regression test for