You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement Diagram.trace(table_expr) as the upstream mirror of Diagram.cascade() — walking the FK graph upward from a restricted table expression, propagating the key restriction through every ancestor with OR convergence.
PR #1407 delivered downstream graph operations (Diagram.cascade() and Diagram.restrict()). The upstream direction is missing — users cannot programmatically walk the FK graph upward to find which ancestor entities contributed to a given result.
Design
Diagram.trace(table_expr) constructs a restricted upstream diagram:
Summary
Implement
Diagram.trace(table_expr)as the upstream mirror ofDiagram.cascade()— walking the FK graph upward from a restricted table expression, propagating the key restriction through every ancestor with OR convergence.Context
Discussion: #1232
Related: #242 (farfetch), PR #1407 (graph-driven cascade)
PR #1407 delivered downstream graph operations (
Diagram.cascade()andDiagram.restrict()). The upstream direction is missing — users cannot programmatically walk the FK graph upward to find which ancestor entities contributed to a given result.Design
Diagram.trace(table_expr)constructs a restricted upstream diagram:trace[TableClass]: returns the ancestor table pre-restricted through the FK join pathtrace.counts(): entity counts per ancestor tabletrace.heading(): all attributes across ancestor tables, grouped by tableConvergence rules
cascaderestricttraceRestriction propagation (inverse of cascade)
For edge Parent→Child with
attr_map, trace reverses the propagation: project child FK values back onto parent primary keys.Implementation notes
trace[TableClass]via__getitem__— only table classes acceptedQueryExpressionobjects — all existing query operators (join, aggr, proj, restrict) and fetch methods work unchanged