Ray's Knowledge Base
Unlock

A schemaless View's batch-collected frame lacks declared columns, so joins misalign

PitfallVerified 29 Sep 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A LazyFrame join over a schemaless (ndjson) View put a column in the wrong place; a later expression failed with expr: coalesce needs one type, got int64 and string, and a select over the planned names threw select: no column named app. The plan/explain showed scan [app, i, run, type] but the join received left: i run type cols=3.

Cause#

When a plan has child plans (a join's right side), LazyFrame collect batches the leaf sources (batch_leaves -> ViewSource::collect_batch / open_batch). The View source returns frames holding only the fields the matched records carry, not its declared schema() (from the index catalog), and those frames have no name_ids, so AlignCursor never runs. Positional ops above then pair names with the wrong columns. Also: MapSource and stream() hide child plans, so no shared scan happens through them.

Fix#

In src/dftracer/utils/trace/views/view_source.cpp, lay every batch-collected frame (collect_batch and the finished frames in run_open_batch) out as the member's declared schema: declared columns in order, a missing one as Series::nulls of its type (String when Unknown/List/Struct), extra columns appended. Verified by the duql joins tests and a debug print of the probe's left names.

Evidence#

duql-joins change, 2026-09-29: test_view_duql_joins determinism case failed before, passed after on 1, 2 and 8 workers.

Also found by searching

  • expr: coalesce needs one type, got int64 and string; select: no column named app after LazyFrame join
  • a join over an ndjson trace view puts columns in the wrong positions even though explain shows the right scan
  • why do batch-collected View frames miss declared columns and misalign joins in schemaless traces?
  • ViewSource collect_batch frames lack name_ids, AlignCursor never runs, join left cols=3
  • expr: coalesce needs one type, got int64 and string after LazyFrame join on ndjson View
  • select: no column named app thrown after join over schemaless view
  • LazyFrame join of View puts column in wrong place, scan [app, i, run, type] but join got cols=3
  • joins misalign with batch_leaves collect_batch when records lack some fields