Skip to content

Commit

Permalink
add two more unit test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiayu Liu committed Jun 8, 2021
1 parent 1e4c160 commit cfa25b3
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions arrow/src/compute/kernels/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ mod tests {
use super::*;
use crate::array::*;
use crate::compute::SortOptions;
use crate::datatypes::DataType;
use std::sync::Arc;

#[test]
Expand Down Expand Up @@ -153,6 +154,55 @@ mod tests {
Ok(())
}

#[test]
fn test_lexicographical_partition_all_equal_values() -> Result<()> {
let input = vec![SortColumn {
values: Arc::new(Int64Array::from_value(1, 1000)) as ArrayRef,
options: Some(SortOptions {
descending: false,
nulls_first: true,
}),
}];
{
let results = lexicographical_partition_points(&input)?;
assert_eq!(vec![0, 1000], results);
}
{
let results = lexicographical_partition_ranges(&input)?;
assert_eq!(vec![(0_usize..1000_usize)], results);
}
Ok(())
}

#[test]
fn test_lexicographical_partition_all_null_values() -> Result<()> {
let input = vec![
SortColumn {
values: new_null_array(&DataType::Int8, 1000),
options: Some(SortOptions {
descending: false,
nulls_first: true,
}),
},
SortColumn {
values: new_null_array(&DataType::UInt16, 1000),
options: Some(SortOptions {
descending: false,
nulls_first: false,
}),
},
];
{
let results = lexicographical_partition_points(&input)?;
assert_eq!(vec![0, 1000], results);
}
{
let results = lexicographical_partition_ranges(&input)?;
assert_eq!(vec![(0_usize..1000_usize)], results);
}
Ok(())
}

#[test]
fn test_lexicographical_partition_unique_column_1() -> Result<()> {
let input = vec![
Expand Down

0 comments on commit cfa25b3

Please sign in to comment.