Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Remove binary support
Browse files Browse the repository at this point in the history
Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo committed Dec 6, 2021
1 parent 6eba31a commit 82906c2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 92 deletions.
10 changes: 1 addition & 9 deletions src/compute/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ fn utf8_lower<O: Offset>(array: &Utf8Array<O>) -> Utf8Array<O> {
/// this function errors when the passed array is not a \[Large\]String array.
pub fn lower(array: &dyn Array) -> Result<Box<dyn Array>> {
match array.data_type() {
// For binary and large binary, lower is no-op.
DataType::Binary | DataType::LargeBinary => unsafe {
// Safety: we will use the whole slice directly, so we don't need to check it.
Ok(array.slice_unchecked(0, array.len()))
},
DataType::LargeUtf8 => Ok(Box::new(utf8_lower(
array
.as_any()
Expand Down Expand Up @@ -72,8 +67,5 @@ pub fn lower(array: &dyn Array) -> Result<Box<dyn Array>> {
/// assert_eq!(can_lower(&data_type), false);
/// ```
pub fn can_lower(data_type: &DataType) -> bool {
matches!(
data_type,
DataType::LargeUtf8 | DataType::Utf8 | DataType::LargeBinary | DataType::Binary
)
matches!(data_type, DataType::LargeUtf8 | DataType::Utf8)
}
83 changes: 0 additions & 83 deletions tests/it/compute/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,89 +82,6 @@ fn without_nulls_large_string() -> Result<()> {
without_nulls_utf8::<i64>()
}

fn with_null_binarys<O: Offset>() -> Result<()> {
let cases = vec![
// identity
(
vec![Some(b"hello"), None, Some(b"world")],
vec![Some(b"hello"), None, Some(b"world")],
),
// part of input
(
vec![Some(b"Hello"), None, Some(b"wOrld")],
vec![Some(b"Hello"), None, Some(b"wOrld")],
),
// all input
(
vec![Some(b"HELLO"), None, Some(b"WORLD")],
vec![Some(b"HELLO"), None, Some(b"WORLD")],
),
];

cases
.into_iter()
.try_for_each::<_, Result<()>>(|(array, expected)| {
let array = BinaryArray::<O>::from(&array);
let result = lower(&array)?;
assert_eq!(array.len(), result.len());

let result = result.as_any().downcast_ref::<BinaryArray<O>>().unwrap();
let expected = BinaryArray::<O>::from(&expected);

assert_eq!(&expected, result);
Ok(())
})?;

Ok(())
}

#[test]
fn with_nulls_binary() -> Result<()> {
with_null_binarys::<i32>()
}

#[test]
fn with_nulls_large_binary() -> Result<()> {
with_null_binarys::<i64>()
}

fn without_null_binarys<O: Offset>() -> Result<()> {
let cases = vec![
// identity
(vec![b"hello", b"world"], vec![b"hello", b"world"]),
// part of input
(vec![b"Hello", b"wOrld"], vec![b"Hello", b"wOrld"]),
// all input
(vec![b"HELLO", b"WORLD"], vec![b"HELLO", b"WORLD"]),
];

cases
.into_iter()
.try_for_each::<_, Result<()>>(|(array, expected)| {
let array = BinaryArray::<O>::from_slice(&array);
let result = lower(&array)?;
assert_eq!(array.len(), result.len());

let result = result.as_any().downcast_ref::<BinaryArray<O>>().unwrap();
let expected = BinaryArray::<O>::from_slice(&expected);

assert_eq!(&expected, result);
Ok(())
})?;

Ok(())
}

#[test]
fn without_nulls_binary() -> Result<()> {
without_null_binarys::<i32>()
}

#[test]
fn without_nulls_large_binary() -> Result<()> {
without_null_binarys::<i64>()
}

#[test]
fn consistency() {
use arrow2::datatypes::DataType::*;
Expand Down

0 comments on commit 82906c2

Please sign in to comment.