Skip to content

Commit e799557

Browse files
authored
Migrate arrow-select to Rust 2024 (#8490)
# Which issue does this PR close? - Contribute to #6827 # Rationale for this change Splitting up #8227. # What changes are included in this PR? Migrate `arrow-select` to Rust 2024 # Are these changes tested? CI # Are there any user-facing changes? Yes
1 parent 04cd6cf commit e799557

File tree

10 files changed

+61
-45
lines changed

10 files changed

+61
-45
lines changed

arrow-select/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ authors = { workspace = true }
2525
license = { workspace = true }
2626
keywords = { workspace = true }
2727
include = { workspace = true }
28-
edition = { workspace = true }
28+
edition = "2024"
2929
rust-version = { workspace = true }
3030

3131
[lib]

arrow-select/src/coalesce.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
//! [`take`]: crate::take::take
2323
use crate::filter::filter_record_batch;
2424
use arrow_array::types::{BinaryViewType, StringViewType};
25-
use arrow_array::{downcast_primitive, Array, ArrayRef, BooleanArray, RecordBatch};
25+
use arrow_array::{Array, ArrayRef, BooleanArray, RecordBatch, downcast_primitive};
2626
use arrow_schema::{ArrowError, DataType, SchemaRef};
2727
use std::collections::VecDeque;
2828
use std::sync::Arc;
@@ -1400,13 +1400,11 @@ mod tests {
14001400

14011401
/// Return a RecordBatch of 100 rows
14021402
fn multi_column_batch(range: Range<i32>) -> RecordBatch {
1403-
let int64_array = Int64Array::from_iter(range.clone().map(|v| {
1404-
if v % 5 == 0 {
1405-
None
1406-
} else {
1407-
Some(v as i64)
1408-
}
1409-
}));
1403+
let int64_array = Int64Array::from_iter(
1404+
range
1405+
.clone()
1406+
.map(|v| if v % 5 == 0 { None } else { Some(v as i64) }),
1407+
);
14101408
let string_view_array = StringViewArray::from_iter(range.clone().map(|v| {
14111409
if v % 5 == 0 {
14121410
None

arrow-select/src/concat.rs

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ use arrow_array::cast::AsArray;
3838
use arrow_array::types::*;
3939
use arrow_array::*;
4040
use arrow_buffer::{ArrowNativeType, BooleanBufferBuilder, NullBuffer, OffsetBuffer};
41-
use arrow_data::transform::{Capacities, MutableArrayData};
4241
use arrow_data::ArrayDataBuilder;
42+
use arrow_data::transform::{Capacities, MutableArrayData};
4343
use arrow_schema::{ArrowError, DataType, FieldRef, Fields, SchemaRef};
4444
use std::{collections::HashSet, ops::Add, sync::Arc};
4545

@@ -549,7 +549,10 @@ mod tests {
549549
&PrimitiveArray::<Int32Type>::from(vec![Some(-1), Some(2), None]),
550550
]);
551551

552-
assert_eq!(re.unwrap_err().to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32).");
552+
assert_eq!(
553+
re.unwrap_err().to_string(),
554+
"Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32)."
555+
);
553556
}
554557

555558
#[test]
@@ -572,7 +575,10 @@ mod tests {
572575
&PrimitiveArray::<Float32Type>::from(vec![Some(1.0), Some(2.0), None]),
573576
]);
574577

575-
assert_eq!(re.unwrap_err().to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32).");
578+
assert_eq!(
579+
re.unwrap_err().to_string(),
580+
"Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32)."
581+
);
576582
}
577583

578584
#[test]
@@ -596,7 +602,10 @@ mod tests {
596602
&PrimitiveArray::<Float64Type>::from(vec![Some(1.0), Some(2.0), None]),
597603
]);
598604

599-
assert_eq!(re.unwrap_err().to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32, ...).");
605+
assert_eq!(
606+
re.unwrap_err().to_string(),
607+
"Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32, ...)."
608+
);
600609
}
601610

602611
#[test]
@@ -622,7 +631,10 @@ mod tests {
622631
&BooleanArray::from(vec![Some(true), Some(false), None]),
623632
]);
624633

625-
assert_eq!(re.unwrap_err().to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32, ...).");
634+
assert_eq!(
635+
re.unwrap_err().to_string(),
636+
"Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32, ...)."
637+
);
626638
}
627639

628640
#[test]
@@ -1154,12 +1166,14 @@ mod tests {
11541166
// Verify pointer equality check succeeds, and therefore the
11551167
// dictionaries are not merged. A single values buffer should be reused
11561168
// in this case.
1157-
assert!(dict.values().to_data().ptr_eq(
1158-
&result_same_dictionary
1159-
.as_dictionary::<Int8Type>()
1160-
.values()
1161-
.to_data()
1162-
));
1169+
assert!(
1170+
dict.values().to_data().ptr_eq(
1171+
&result_same_dictionary
1172+
.as_dictionary::<Int8Type>()
1173+
.values()
1174+
.to_data()
1175+
)
1176+
);
11631177
assert_eq!(
11641178
result_same_dictionary
11651179
.as_dictionary::<Int8Type>()
@@ -1222,10 +1236,12 @@ mod tests {
12221236
);
12231237

12241238
// Should have reused the dictionary
1225-
assert!(array
1226-
.values()
1227-
.to_data()
1228-
.ptr_eq(&combined.values().to_data()));
1239+
assert!(
1240+
array
1241+
.values()
1242+
.to_data()
1243+
.ptr_eq(&combined.values().to_data())
1244+
);
12291245
assert!(copy.values().to_data().ptr_eq(&combined.values().to_data()));
12301246

12311247
let new: DictionaryArray<Int8Type> = vec!["d"].into_iter().collect();
@@ -1316,7 +1332,10 @@ mod tests {
13161332
.unwrap();
13171333

13181334
let error = concat_batches(&schema1, [&batch1, &batch2]).unwrap_err();
1319-
assert_eq!(error.to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int32, Utf8).");
1335+
assert_eq!(
1336+
error.to_string(),
1337+
"Invalid argument error: It is not possible to concatenate arrays of different data types (Int32, Utf8)."
1338+
);
13201339
}
13211340

13221341
#[test]
@@ -1481,7 +1500,6 @@ mod tests {
14811500
K: ArrowDictionaryKeyType,
14821501
V: Sync + Send + 'static,
14831502
&'a V: ArrayAccessor + IntoIterator,
1484-
14851503
<&'a V as ArrayAccessor>::Item: Default + Clone + PartialEq + Debug + Ord,
14861504
<&'a V as IntoIterator>::Item: Clone + PartialEq + Debug + Ord,
14871505
{

arrow-select/src/dictionary.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ use arrow_array::types::{
2727
ArrowDictionaryKeyType, ArrowPrimitiveType, BinaryType, ByteArrayType, LargeBinaryType,
2828
LargeUtf8Type, Utf8Type,
2929
};
30-
use arrow_array::{cast::AsArray, downcast_primitive};
3130
use arrow_array::{
32-
downcast_dictionary_array, AnyDictionaryArray, Array, ArrayRef, ArrowNativeTypeOp,
33-
BooleanArray, DictionaryArray, GenericByteArray, PrimitiveArray,
31+
AnyDictionaryArray, Array, ArrayRef, ArrowNativeTypeOp, BooleanArray, DictionaryArray,
32+
GenericByteArray, PrimitiveArray, downcast_dictionary_array,
3433
};
34+
use arrow_array::{cast::AsArray, downcast_primitive};
3535
use arrow_buffer::{ArrowNativeType, BooleanBuffer, ScalarBuffer, ToByteSlice};
3636
use arrow_schema::{ArrowError, DataType};
3737

@@ -365,9 +365,9 @@ mod tests {
365365
use super::*;
366366

367367
use arrow_array::cast::as_string_array;
368-
use arrow_array::types::Int32Type;
369368
use arrow_array::types::Int8Type;
370-
use arrow_array::{DictionaryArray, Int32Array, Int8Array, StringArray};
369+
use arrow_array::types::Int32Type;
370+
use arrow_array::{DictionaryArray, Int8Array, Int32Array, StringArray};
371371
use arrow_buffer::{BooleanBuffer, Buffer, NullBuffer, OffsetBuffer};
372372
use std::sync::Arc;
373373

arrow-select/src/filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ use arrow_array::types::{
2626
ArrowDictionaryKeyType, ArrowPrimitiveType, ByteArrayType, ByteViewType, RunEndIndexType,
2727
};
2828
use arrow_array::*;
29-
use arrow_buffer::{bit_util, ArrowNativeType, BooleanBuffer, NullBuffer, RunEndBuffer};
29+
use arrow_buffer::{ArrowNativeType, BooleanBuffer, NullBuffer, RunEndBuffer, bit_util};
3030
use arrow_buffer::{Buffer, MutableBuffer};
31+
use arrow_data::ArrayDataBuilder;
3132
use arrow_data::bit_iterator::{BitIndexIterator, BitSliceIterator};
3233
use arrow_data::transform::MutableArrayData;
33-
use arrow_data::ArrayDataBuilder;
3434
use arrow_schema::*;
3535

3636
/// If the filter selects more than this fraction of rows, use

arrow-select/src/interleave.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use arrow_array::cast::AsArray;
2323
use arrow_array::types::*;
2424
use arrow_array::*;
2525
use arrow_buffer::{ArrowNativeType, BooleanBuffer, MutableBuffer, NullBuffer, OffsetBuffer};
26-
use arrow_data::transform::MutableArrayData;
2726
use arrow_data::ByteView;
27+
use arrow_data::transform::MutableArrayData;
2828
use arrow_schema::{ArrowError, DataType, Fields};
2929
use std::sync::Arc;
3030

@@ -402,8 +402,8 @@ pub fn interleave_record_batch(
402402
#[cfg(test)]
403403
mod tests {
404404
use super::*;
405-
use arrow_array::builder::{Int32Builder, ListBuilder, PrimitiveRunBuilder};
406405
use arrow_array::Int32RunArray;
406+
use arrow_array::builder::{Int32Builder, ListBuilder, PrimitiveRunBuilder};
407407
use arrow_schema::Field;
408408

409409
#[test]

arrow-select/src/nullif.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
//! Implements the `nullif` function for Arrow arrays.
1919
20-
use arrow_array::{make_array, Array, ArrayRef, BooleanArray};
20+
use arrow_array::{Array, ArrayRef, BooleanArray, make_array};
2121
use arrow_buffer::buffer::{bitwise_bin_op_helper, bitwise_unary_op_helper};
2222
use arrow_buffer::{BooleanBuffer, NullBuffer};
2323
use arrow_schema::{ArrowError, DataType};
@@ -120,7 +120,7 @@ mod tests {
120120
use arrow_array::{Int32Array, NullArray, StringArray, StructArray};
121121
use arrow_data::ArrayData;
122122
use arrow_schema::{Field, Fields};
123-
use rand::{rng, Rng};
123+
use rand::{Rng, rng};
124124

125125
#[test]
126126
fn test_nullif_int_array() {

arrow-select/src/take.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ use arrow_array::cast::AsArray;
2424
use arrow_array::types::*;
2525
use arrow_array::*;
2626
use arrow_buffer::{
27-
bit_util, ArrowNativeType, BooleanBuffer, Buffer, MutableBuffer, NullBuffer, OffsetBuffer,
28-
ScalarBuffer,
27+
ArrowNativeType, BooleanBuffer, Buffer, MutableBuffer, NullBuffer, OffsetBuffer, ScalarBuffer,
28+
bit_util,
2929
};
3030
use arrow_data::ArrayDataBuilder;
3131
use arrow_schema::{ArrowError, DataType, FieldRef, UnionMode};

arrow-select/src/union_extract.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
2020
use crate::take::take;
2121
use arrow_array::{
22-
make_array, new_empty_array, new_null_array, Array, ArrayRef, BooleanArray, Int32Array, Scalar,
23-
UnionArray,
22+
Array, ArrayRef, BooleanArray, Int32Array, Scalar, UnionArray, make_array, new_empty_array,
23+
new_null_array,
2424
};
25-
use arrow_buffer::{bit_util, BooleanBuffer, MutableBuffer, NullBuffer, ScalarBuffer};
25+
use arrow_buffer::{BooleanBuffer, MutableBuffer, NullBuffer, ScalarBuffer, bit_util};
2626
use arrow_data::layout;
2727
use arrow_schema::{ArrowError, DataType, UnionFields};
2828
use std::cmp::Ordering;
@@ -399,8 +399,8 @@ fn is_sequential_generic<const N: usize>(offsets: &[i32]) -> bool {
399399

400400
#[cfg(test)]
401401
mod tests {
402-
use super::{eq_scalar_inner, is_sequential_generic, union_extract, BoolValue};
403-
use arrow_array::{new_null_array, Array, Int32Array, NullArray, StringArray, UnionArray};
402+
use super::{BoolValue, eq_scalar_inner, is_sequential_generic, union_extract};
403+
use arrow_array::{Array, Int32Array, NullArray, StringArray, UnionArray, new_null_array};
404404
use arrow_buffer::{BooleanBuffer, ScalarBuffer};
405405
use arrow_schema::{ArrowError, DataType, Field, UnionFields, UnionMode};
406406
use std::sync::Arc;

arrow-select/src/window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! Defines windowing functions, like `shift`ing
1919
2020
use crate::concat::concat;
21-
use arrow_array::{make_array, new_null_array, Array, ArrayRef};
21+
use arrow_array::{Array, ArrayRef, make_array, new_null_array};
2222
use arrow_schema::ArrowError;
2323
use num_traits::abs;
2424

0 commit comments

Comments
 (0)