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
{{ message }}
Repository navigation
Struct compatibility checks are quadratic in struct width #27905
Is your feature request related to a problem or challenge?
Struct compatibility checks are quadratic in struct width. map_struct_fields in datafusion/common/src/nested_struct.rs searches the source fields linearly for every target field. It backs validate_struct_compatibility and cast_struct_column, so it runs whenever a file's struct schema differs from the table schema: during physical expression adaptation, once per file and per expression, and again when batches are cast.
This hurts tables with wide struct columns. We store OpenTelemetry attributes as a struct with one field per attribute key, often thousands of fields. On a query over 109 files with six struct-field projections and one struct-field filter, a CPU profile of the query process showed about 70% of samples in byte-slice equality called from map_struct_fields and its callers. The query ran into a 60 s timeout.
A standalone benchmark of validate_struct_compatibility, where the source holds every other field of the target:
Target fields
Time per call
100
12.7 µs
1,000
1.21 ms
10,000
105 ms
Describe the solution you'd like
Build a name-to-index map of the source fields once per call and use it for the overlap check and for each target field lookup. Keep the existing semantics: the first source field wins when names repeat.
Activity