diff --git a/arrow-arith/src/aggregate.rs b/arrow-arith/src/aggregate.rs index 2e5713dd7d06..b09dd96a00fd 100644 --- a/arrow-arith/src/aggregate.rs +++ b/arrow-arith/src/aggregate.rs @@ -1580,7 +1580,12 @@ mod tests { Some("c".as_bytes()) ); - test_binary!(test_binary_min_max_all_nulls, vec![None, None], None, None); + test_binary!( + test_binary_min_max_all_nulls, + vec![None::<&[u8]>, None], + None, + None + ); test_binary!( test_binary_min_max_1, diff --git a/arrow-array/src/array/binary_array.rs b/arrow-array/src/array/binary_array.rs index b1fbd5729ad7..349ae652bfb9 100644 --- a/arrow-array/src/array/binary_array.rs +++ b/arrow-array/src/array/binary_array.rs @@ -96,7 +96,29 @@ impl GenericBinaryArray { impl From>> for GenericBinaryArray { fn from(v: Vec>) -> Self { - Self::from_opt_vec(v) + v.into_iter().collect() + } +} + +impl From>> + for GenericBinaryArray +{ + fn from(v: Vec>) -> Self { + v.into_iter().collect() + } +} + +impl From>> + for GenericBinaryArray +{ + fn from(v: Vec>) -> Self { + v.into_iter().collect() + } +} + +impl From>>> for GenericBinaryArray { + fn from(v: Vec>>) -> Self { + v.into_iter().collect() } } @@ -106,6 +128,28 @@ impl From> for GenericBinaryArray From> + for GenericBinaryArray +{ + fn from(v: Vec<[u8; C]>) -> Self { + Self::from_iter_values(v) + } +} + +impl From> + for GenericBinaryArray +{ + fn from(v: Vec<&[u8; C]>) -> Self { + Self::from_iter_values(v) + } +} + +impl From>> for GenericBinaryArray { + fn from(v: Vec>) -> Self { + Self::from_iter_values(v) + } +} + impl From> for GenericBinaryArray { fn from(v: GenericListArray) -> Self { Self::from_list(v) @@ -575,7 +619,7 @@ mod tests { #[test] fn test_binary_array_all_null() { - let data = vec![None]; + let data = vec![None::<&[u8]>]; let array = BinaryArray::from(data); array .into_data() @@ -585,7 +629,7 @@ mod tests { #[test] fn test_large_binary_array_all_null() { - let data = vec![None]; + let data = vec![None::<&[u8]>]; let array = LargeBinaryArray::from(data); array .into_data() diff --git a/arrow-array/src/array/byte_view_array.rs b/arrow-array/src/array/byte_view_array.rs index 58b5ce7a0569..3369d2833277 100644 --- a/arrow-array/src/array/byte_view_array.rs +++ b/arrow-array/src/array/byte_view_array.rs @@ -1140,12 +1140,48 @@ impl From> for BinaryViewArray { } } +impl From> for BinaryViewArray { + fn from(v: Vec<[u8; C]>) -> Self { + Self::from_iter_values(v) + } +} + +impl From> for BinaryViewArray { + fn from(v: Vec<&[u8; C]>) -> Self { + Self::from_iter_values(v) + } +} + +impl From>> for BinaryViewArray { + fn from(v: Vec>) -> Self { + Self::from_iter_values(v) + } +} + impl From>> for BinaryViewArray { fn from(v: Vec>) -> Self { v.into_iter().collect() } } +impl From>> for BinaryViewArray { + fn from(v: Vec>) -> Self { + v.into_iter().collect() + } +} + +impl From>> for BinaryViewArray { + fn from(v: Vec>) -> Self { + v.into_iter().collect() + } +} + +impl From>>> for BinaryViewArray { + fn from(v: Vec>>) -> Self { + v.into_iter().collect() + } +} + /// A [`GenericByteViewArray`] that stores utf8 data /// /// See [`GenericByteViewArray`] for format and layout details. diff --git a/arrow-array/src/record_batch.rs b/arrow-array/src/record_batch.rs index e05450a97f7f..6c6817e51eb1 100644 --- a/arrow-array/src/record_batch.rs +++ b/arrow-array/src/record_batch.rs @@ -115,7 +115,9 @@ macro_rules! create_array { (@from TimestampMillisecond) => { $crate::TimestampMillisecondArray }; (@from TimestampMicrosecond) => { $crate::TimestampMicrosecondArray }; (@from TimestampNanosecond) => { $crate::TimestampNanosecondArray }; - + (@from Binary) => { $crate::BinaryArray }; + (@from BinaryView) => { $crate::BinaryViewArray }; + (@from LargeBinary) => { $crate::LargeBinaryArray }; (@from $ty: ident) => { compile_error!(concat!("Unsupported data type: ", stringify!($ty))) }; @@ -124,26 +126,10 @@ macro_rules! create_array { std::sync::Arc::new($crate::NullArray::new($size)) }; - (Binary, [$($values: expr),*]) => { - std::sync::Arc::new($crate::BinaryArray::from_vec(vec![$($values),*])) - }; - - (LargeBinary, [$($values: expr),*]) => { - std::sync::Arc::new($crate::LargeBinaryArray::from_vec(vec![$($values),*])) - }; - ($ty: tt, [$($values: expr),*]) => { std::sync::Arc::new(<$crate::create_array!(@from $ty)>::from(vec![$($values),*])) }; - (Binary, $values: expr) => { - std::sync::Arc::new($crate::BinaryArray::from_vec($values)) - }; - - (LargeBinary, $values: expr) => { - std::sync::Arc::new($crate::LargeBinaryArray::from_vec($values)) - }; - ($ty: tt, $values: expr) => { std::sync::Arc::new(<$crate::create_array!(@from $ty)>::from($values)) };