Skip to content

Commit

Permalink
add test for min_max_schema_for_fields (#1122)
Browse files Browse the repository at this point in the history
Signed-off-by: Marijn Valk <[email protected]>

# Description
Adds tests for `min_max_schema_for_fields`

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

- closes #106
--->

# Documentation

<!---
Share links to useful documentation
--->

---------

Signed-off-by: Marijn Valk <[email protected]>
  • Loading branch information
marijncv authored Feb 6, 2023
1 parent 5ab9383 commit 8a82f79
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions rust/src/delta_arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,4 +732,49 @@ mod tests {
crate::SchemaDataType::primitive("timestamp".to_string())
);
}

#[test]
fn test_max_min_schema_for_fields() {
let mut max_min_vec: Vec<ArrowField> = Vec::new();
let fields = [
ArrowField::new("simple", ArrowDataType::Int32, true),
ArrowField::new(
"struct",
ArrowDataType::Struct(vec![ArrowField::new("simple", ArrowDataType::Int32, true)]),
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,
),
];

let expected = vec![fields[0].clone(), fields[1].clone()];

fields
.iter()
.for_each(|f| max_min_schema_for_fields(&mut max_min_vec, f));

assert_eq!(max_min_vec, expected);
}
}

0 comments on commit 8a82f79

Please sign in to comment.