Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Struct union type coercion takes field nullability from the wrong field when field order differs

Offen Anfängerfreundlich
#26,296 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@med9110 arbeitet bereits daran.

Seit 14.10.2026.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
rust
Bereich
databases

Rechercherichtung

Beginne im (DataType::Struct(lhs), DataType::Struct(rhs))-Zweig, der in type_union_resolution_coercion in datafusion/expr-common/src/type_coercion/binary.rs liegt. Lass search_corresponding_coerced_type außerdem das namensgleiche rhs-Feld zurückgeben und übergib dieses Feld an coerce_fields statt des positionsbasierten zip. Führe die vorhandenen Tests zur Struct-Union-Coercion in dieser Datei aus und füge einen Fall mit vertauschter Feldreihenfolge hinzu. Fertig ist es, wenn Struct { a: Int32 NOT NULL, b: Int32 NOT NULL } mit Struct { b: Int32 NULL, a: Int32 NOT NULL } vereinigt Struct { a: Int32 NOT NULL, b: Int32 NULL } ergibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug help wanted logical-expr tech debt
Describe the bug

In the (DataType::Struct(lhs), DataType::Struct(rhs)) arm of type_union_resolution_coercion (type_coercion/binary.rs#L835-L872), each field's coerced type is computed by matching fields by name (search_corresponding_coerced_type), but the field's nullability is computed by zipping lhs and rhs positionally:

let coerced_types = lhs
    .iter()
    .map(|lhs_field| search_corresponding_coerced_type(lhs_field, rhs))
    .collect::<Option<Vec<_>>>()?;

// preserve the field name and nullability
let orig_fields = std::iter::zip(lhs.iter(), rhs.iter());

let fields: Vec<FieldRef> = coerced_types
    .into_iter()
    .zip(orig_fields)
    .map(|(datatype, (lhs, rhs))| coerce_fields(datatype, lhs, rhs))
    .collect();

coerce_fields sets nullable = lhs.is_nullable() || rhs.is_nullable(). When the two structs have the same field names in a different order, the nullability of each output field comes from an unrelated right-hand field.

To Reproduce

Resolve the union type of:

  • lhs = Struct { a: Int32 NOT NULL, b: Int32 NOT NULL }
  • rhs = Struct { b: Int32 NULL, a: Int32 NOT NULL }

The result is Struct { a: Int32 NULL, b: Int32 NOT NULL }. Field b is reported as non-nullable even though the right-hand b can contain nulls (and a is needlessly marked nullable).

Expected behavior

Nullability is taken from the name-matched pair, giving Struct { a: Int32 NOT NULL, b: Int32 NULL }. For example, have search_corresponding_coerced_type return the matched rhs_field along with the coerced type, and pass that field to coerce_fields.

Additional context

The nearby try_type_union_resolution_with_struct (about L900-L970) walks data_types three times, each re-matching DataType::Struct with an internal_err! fallback the first loop already rules out. It may be worth simplifying in the same change.

Line references are pinned to commit 0d79252f61bd.

Vorherrschende Sprache
Rust
Sterne
9.4k
Forks
2.5k
Ø Merge
4 T. 13 Std.
Gemergte PRs (30 T.)
353

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/datafusion

Alle Issues in apache/datafusion

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.