Every leaf of a Parquet file carries, for each of its value slots, the
definition level (how deep the path to the value is actually present) and the
repetition level (at which level of nesting the value repeats). Those two
numbers are enough to rebuild the whole nested structure, and that is what
build_field does — one Arrow array per Arrow field, recursively.
The key idea is a presence threshold. A field is asked to build only the
slots whose definition level is at least require_def, which its parent sets:
- the root asks for
require_def = 0, so every slot is a row;
- a
LIST or MAP asks its child for require_def = elem_def_level, the
definition level at which the repeated group actually has an entry — so the
child array comes back already containing exactly the list's elements, with
the empty and null containers dropped;
- a
STRUCT passes its own threshold straight through, because a struct does
not change granularity.
Levels come from the field's first descendant leaf. Every leaf under a field
agrees about the levels at and above that field, so any one of them will do —
which is what makes it possible to build a struct's children independently and
still have them line up.