Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 39 additions & 70 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ ahash = { version = "0.8", default-features = false, features = [
"runtime-rng",
] }
apache-avro = { version = "0.21", default-features = false }
arrow = { version = "57.1.0", features = [
arrow = { version = "57.2.0", features = [
"prettyprint",
"chrono-tz",
] }
arrow-buffer = { version = "57.1.0", default-features = false }
arrow-flight = { version = "57.1.0", features = [
arrow-buffer = { version = "57.2.0", default-features = false }
arrow-flight = { version = "57.2.0", features = [
"flight-sql-experimental",
] }
arrow-ipc = { version = "57.1.0", default-features = false, features = [
arrow-ipc = { version = "57.2.0", default-features = false, features = [
"lz4",
] }
arrow-ord = { version = "57.1.0", default-features = false }
arrow-schema = { version = "57.1.0", default-features = false }
arrow-ord = { version = "57.2.0", default-features = false }
arrow-schema = { version = "57.2.0", default-features = false }
async-trait = "0.1.89"
bigdecimal = "0.4.8"
bytes = "1.11"
Expand Down Expand Up @@ -166,7 +166,7 @@ log = "^0.4"
num-traits = { version = "0.2" }
object_store = { version = "0.12.4", default-features = false }
parking_lot = "0.12"
parquet = { version = "57.1.0", default-features = false, features = [
parquet = { version = "57.2.0", default-features = false, features = [
"arrow",
"async",
"object_store",
Expand Down
7 changes: 4 additions & 3 deletions datafusion/common/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8868,7 +8868,7 @@ mod tests {
.unwrap(),
ScalarValue::try_new_null(&DataType::Map(map_field_ref, false)).unwrap(),
ScalarValue::try_new_null(&DataType::Union(
UnionFields::new(vec![42], vec![field_ref]),
UnionFields::try_new(vec![42], vec![field_ref]).unwrap(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnionMode::Dense,
))
.unwrap(),
Expand Down Expand Up @@ -8971,13 +8971,14 @@ mod tests {
}

// Test union type
let union_fields = UnionFields::new(
let union_fields = UnionFields::try_new(
vec![0, 1],
vec![
Field::new("i32", DataType::Int32, false),
Field::new("f64", DataType::Float64, false),
],
);
)
.unwrap();
let union_result = ScalarValue::new_default(&DataType::Union(
union_fields.clone(),
UnionMode::Sparse,
Expand Down
5 changes: 4 additions & 1 deletion datafusion/datasource-avro/src/avro_to_arrow/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ fn schema_to_field_with_props(
.map(|s| schema_to_field_with_props(s, None, has_nullable, None))
.collect::<Result<Vec<Field>>>()?;
let type_ids = 0_i8..fields.len() as i8;
DataType::Union(UnionFields::new(type_ids, fields), UnionMode::Dense)
DataType::Union(
UnionFields::try_new(type_ids, fields).unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we propagate this unwrap?

Copy link
Contributor

@friendlymatthew friendlymatthew Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the type_ids are autoincrementing, we can probably use UnionFields::from_fields(fields) and avoid the Result

UnionFields::from_fields is a convenience constructor that will infallibly construct the UnionFields (since the only check we really need is to ensure type id uniqueness). https://docs.rs/arrow/latest/arrow/datatypes/struct.UnionFields.html#method.from_fields

UnionMode::Dense,
)
}
}
AvroSchema::Record(RecordSchema { fields, .. }) => {
Expand Down
5 changes: 3 additions & 2 deletions datafusion/functions/src/core/union_extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,14 @@ mod tests {
fn test_scalar_value() -> Result<()> {
let fun = UnionExtractFun::new();

let fields = UnionFields::new(
let fields = UnionFields::try_new(
vec![1, 3],
vec![
Field::new("str", DataType::Utf8, false),
Field::new("int", DataType::Int32, false),
],
);
)
.unwrap();

let args = vec![
ColumnarValue::Scalar(ScalarValue::Union(
Expand Down
5 changes: 3 additions & 2 deletions datafusion/physical-plan/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,13 +1557,14 @@ mod tests {
#[test]
fn test_equivalence_properties_union_type() -> Result<()> {
let union_type = DataType::Union(
UnionFields::new(
UnionFields::try_new(
vec![0, 1],
vec![
Field::new("f1", DataType::Int32, true),
Field::new("f2", DataType::Utf8, true),
],
),
)
.unwrap(),
UnionMode::Sparse,
);

Expand Down
Loading