Skip to content

Commit

Permalink
add test for null_count_schema_for_fields (delta-io#1135)
Browse files Browse the repository at this point in the history
# Description
Adds a test for `null_count_schema_for_fields`

# Related Issue(s)
<!---
For example:

- closes delta-io#106
--->

# Documentation

<!---
Share links to useful documentation
--->
  • Loading branch information
marijncv authored and chitralverma committed Mar 17, 2023
1 parent a3bef3c commit 2e75e22
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions rust/src/delta_arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,4 +781,59 @@ mod tests {

assert_eq!(max_min_vec, expected);
}

#[test]
fn test_null_count_schema_for_fields() {
let mut null_count_vec: Vec<ArrowField> = Vec::new();
let fields = [
ArrowField::new("int32", ArrowDataType::Int32, true),
ArrowField::new("int64", ArrowDataType::Int64, true),
ArrowField::new("Utf8", ArrowDataType::Utf8, true),
ArrowField::new(
"list",
ArrowDataType::List(Box::new(ArrowField::new(
"simple",
ArrowDataType::Int32,
true,
))),
true,
),
ArrowField::new(
"map",
ArrowDataType::Map(
Box::new(ArrowField::new(
"struct",
ArrowDataType::Struct(vec![
ArrowField::new("key", ArrowDataType::Int32, true),
ArrowField::new("value", ArrowDataType::Int32, true),
]),
true,
)),
true,
),
true,
),
ArrowField::new(
"struct",
ArrowDataType::Struct(vec![ArrowField::new("int32", ArrowDataType::Int32, true)]),
true,
),
];
let expected = vec![
ArrowField::new(fields[0].name(), ArrowDataType::Int64, true),
ArrowField::new(fields[1].name(), ArrowDataType::Int64, true),
ArrowField::new(fields[2].name(), ArrowDataType::Int64, true),
ArrowField::new(fields[3].name(), ArrowDataType::Int64, true),
ArrowField::new(fields[4].name(), ArrowDataType::Int64, true),
ArrowField::new(
fields[5].name(),
ArrowDataType::Struct(vec![ArrowField::new("int32", ArrowDataType::Int64, true)]),
true,
),
];
fields
.iter()
.for_each(|f| null_count_schema_for_fields(&mut null_count_vec, f));
assert_eq!(null_count_vec, expected);
}
}

0 comments on commit 2e75e22

Please sign in to comment.