Struct union type coercion takes field nullability from the wrong field when field order differs
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
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
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
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus apache/datafusion
-
[Bug] atan2 does not normalize -0.0 the way Spark doesEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenbug spark
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
apache/datafusion#26333 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug help wanted unparser
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
apache/datafusion#26316 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Deduplicate bucket computation in width_bucket_interval_mdn_exactEvtl. vergeben @nightcityblade hat das vor 1 Tag übernommen. Offenenhancement good first issue help wanted spark tech debt
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
apache/datafusion#26307 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Use the shared aggr_test_schema in CSV scan tests instead of a local copyEvtl. vergeben @med9110 hat das vor 1 Tag übernommen. Offencore enhancement good first issue help wanted tech debt
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
apache/datafusion#26306 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
gcd benchmarks pass number_rows: 0 for 100k-row inputsEvtl. vergeben @med9110 hat das vor 1 Tag übernommen. Offenbug functions good first issue help wanted tech debt
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
apache/datafusion#26297 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in apache/datafusion
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
nannou-org/egui_graph#92 ·
Maintainer antworten meist innerhalb von 1 Tag
-
documentation good first issue
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 72/100
sujithputta02/Esapay#13 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
tursodatabase/turso#10002 ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
topgrade-rs/topgrade#2419 ·
Maintainer antworten meist innerhalb von 1 Tag
-
review-bot
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
midagedev/bloomery#318 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag