A LazyFrame child plan of a duql stage collects rows in arrival order, so row order and column types vary per run
Symptom#
duql lookup ... asof over a multi-chunk trace gave different rows on each run: the row order of the output changed, some matches went to another equal-time row, and one run threw lazy frame op 'dftu.frame.asof' failed: the op returned no frame.
Cause#
A side that joins in as a child plan is collected in batch mode. The batch path does not keep file order, even when the View plan is ordered. A column that no record of one chunk holds gets another physical type, which the Arrow-backed op rejects with a null result.
Fix#
Collect the side in the build step before the scan (add its index to term_reads through asof_reads in view_duql.cpp) and make its input scan ordered with ctx.order before any select or with_column; reshape("duql") refuses a View that already has ops. Cast key and time columns to one plan type on both frames every time, not only when the types differ. Restore input order with LazyFrame::sort_by on a row index: sort_by_multi on one column was 3x slower on 1M rows (cmp_row with is_null per compare).
Evidence#
test_view_duql_joins passed 12 of 12 runs after the fix; before it, 1 run in 3 failed. Stage time fell from 5.6 s to 1.65 s on 1M events with the sort_by change.
Also found by searching
- lazy frame op 'dftu.frame.asof' failed: the op returned no frame
- lookup asof gives different rows and order on each run over a multi-chunk trace
- how do I get deterministic order for a LazyFrame child plan joined in duql
- batch collect ignores file order, column physical type differs per chunk Arrow
- lookup asof over multi-chunk trace gives different rows each run, lazy frame op 'dftu.frame.asof' failed: the op returned no frame
- duql asof join nondeterministic row order and some matches go to another equal-time row
- how do I make the child plan side of an asof lookup deterministic with ordered scan?
- column absent in one chunk gets different physical type, Arrow-backed op returns null, cast key and time columns