This is a minimal reproducer for a bug in Apache DataFusion where struct field casting maps values by position instead of by field name.
When casting a struct from one field order to another, DataFusion incorrectly maps values by position rather than by field name.
- Input:
{b: 3, a: 4}
with field order[b, a]
- Target: Field order
[a, b]
- Expected:
{a: 4, b: 3}
(mapped by field name) - Actual:
{a: 3, b: 4}
(mapped by position - BUG!)
cd datafusion_bug
cargo run
The reproducer will show:
❌ BUG: Values mapped by position instead of field name!
Expected (field name mapping):
Source a=4 → Target a=4
Source b=3 → Target b=3
Actual (position mapping):
Source position[0]=3 → Target a=3 (WRONG)
Source position[1]=4 → Target b=4 (WRONG)
DataFusion incorrectly maps struct fields by position, not by name!
- DataFusion version: 49.0
- Arrow version: 55.0
This bug affects any system using DataFusion for struct type casting where field order changes between source and target schemas.