Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte Adaptée aux débutants
#26,296 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@med9110 y travaille déjà.

Depuis le 14/10/2026.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
68/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
rust
Domaine
databases

Piste de recherche

Commence dans la branche (DataType::Struct(lhs), DataType::Struct(rhs)) de type_union_resolution_coercion, dans datafusion/expr-common/src/type_coercion/binary.rs. Fais en sorte que search_corresponding_coerced_type retourne aussi le champ rhs de même nom et passe ce champ à coerce_fields au lieu du zip positionnel. Exécute les tests existants de coercition d'union de struct dans ce fichier et ajoute un cas avec les champs dans l'ordre inverse. C'est terminé lorsque Struct { a: Int32 NOT NULL, b: Int32 NOT NULL } unifié avec Struct { b: Int32 NULL, a: Int32 NOT NULL } donne Struct { a: Int32 NOT NULL, b: Int32 NULL }.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Rust
Étoiles
9.4k
Forks
2.5k
Merge moyen
4 j 9 h
PR mergées (30 j)
329

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de apache/datafusion

Toutes les issues de apache/datafusion

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.