Check whether another parent’s element moves into an empty list
Equal total element counts can conceal changed parent ownership. Retain an empty parent in the small fixture.
Why retaining two elements is insufficient
Preserve total element count and ownership per parent separately when flattening lists. A row containing an empty list differs from a missing parent row. Keeping that distinction supports downstream denominators and observation identity. An audit retaining original per-parent sequences lets Truthound express the ownership comparison. [1, 2, 3]
The reported list.agg row shift
Polars #30023 reports list.agg(element().explode()) returning [[1],[2]] where the result should be [[],[1,2]]. The issue concerns which parent receives an element despite a preserved total. This article does not treat matching totals as restoration of the original lists. [1]
Retain parent IDs and element positions
Retain parent IDs, element positions, and original values, reconciling the sequence for each parent after transformation. Hold outputs whose totals match but ownership differs. Preserve row identity across flattening and define canonical representations for order, missingness, and empty lists. [1, 3]
P1 requires an empty list
In the illustrative input, P1 has an empty inner list and P2 has [1,2]. P1 independently requires []. Actual [] passes; [1] fails because another parent’s element has moved into it. Check P2 and the overall element order separately, even when the total remains 2. [1, 3]
The sequence-table comparison boundary
ColumnPairValidator in Truthound Python SDK 3.3.2 compares actual_element_sequence and reference_element_sequence normalized by the operator for matching parent_id values. Operators define representations of lists, NULL, and empty values. Core does not recover nested offsets, and string normalization remains an input responsibility. [1, 2, 3]
An alternative retaining parent keys
Construct a verified explode-and-regroup alternative keyed by parent ID and reconcile the original sequences again. Existing regressions that retain empty parents reduce another audit’s benefit. Do not deduplicate or redistribute elements merely to restore the expected total. [1, 3]
Application conditions
Retain parent IDs, element positions, order, and canonical empty-list and NULL representations across flattening.
Alternatives
Reconcile a verified explode-and-regroup path retaining parent IDs with original sequences.
Limitations
Sequence comparison does not recover nested offsets and cannot be replaced by matching totals.
Evidence
- Event checked
- Subject checked
- Modified
