Skip to content

Commit e5c70c6

Browse files
committed
fix format.
1 parent 0630979 commit e5c70c6

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

datafusion/core/tests/fuzz_cases/aggregation_fuzzer/data_generator.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
use std::sync::Arc;
1919

20-
use arrow::datatypes::{Date32Type, Date64Type, Float32Type, Float64Type, Int16Type, Int32Type, Int64Type, Int8Type, UInt16Type, UInt32Type, UInt64Type, UInt8Type};
20+
use arrow::datatypes::{
21+
Date32Type, Date64Type, Float32Type, Float64Type, Int16Type, Int32Type, Int64Type,
22+
Int8Type, UInt16Type, UInt32Type, UInt64Type, UInt8Type,
23+
};
2124
use arrow_array::{ArrayRef, RecordBatch};
2225
use arrow_schema::{DataType, Field, Schema};
2326
use datafusion_common::{arrow_datafusion_err, DataFusionError, Result};

test-utils/src/array_gen/primitive.rs

+30-28
Original file line numberDiff line numberDiff line change
@@ -36,43 +36,45 @@ pub struct PrimitiveArrayGenerator {
3636

3737
// TODO: support generating more primitive arrays
3838
impl PrimitiveArrayGenerator {
39-
pub fn gen_data<N, A: ArrowPrimitiveType>(&mut self) -> ArrayRef
39+
pub fn gen_data<N, A>(&mut self) -> ArrayRef
4040
where
4141
A: ArrowPrimitiveType<Native = N>,
4242
N: std::marker::Sync + std::marker::Send,
43-
Standard: Distribution<N>
43+
Standard: Distribution<N>,
4444
{
4545
// table of primitives from which to draw
4646
let distinct_primitives: PrimitiveArray<A> = (0..self.num_distinct_primitives)
47-
.map(|_| Some(match A::DATA_TYPE {
48-
DataType::Int8
49-
| DataType::Int16
50-
| DataType::Int32
51-
| DataType::Int64
52-
| DataType::UInt8
53-
| DataType::UInt16
54-
| DataType::UInt32
55-
| DataType::UInt64
56-
| DataType::Float32
57-
| DataType::Float64
58-
| DataType::Date32 => self.rng.gen::<N>(),
47+
.map(|_| {
48+
Some(match A::DATA_TYPE {
49+
DataType::Int8
50+
| DataType::Int16
51+
| DataType::Int32
52+
| DataType::Int64
53+
| DataType::UInt8
54+
| DataType::UInt16
55+
| DataType::UInt32
56+
| DataType::UInt64
57+
| DataType::Float32
58+
| DataType::Float64
59+
| DataType::Date32 => self.rng.gen::<N>(),
5960

60-
DataType::Date64 => {
61-
// TODO: constrain this range to valid dates if necessary
62-
let date_value = self.rng.gen_range(i64::MIN..=i64::MAX);
63-
let millis_per_day: i64 = 86_400_000;
64-
let adjusted_value = date_value - (date_value % millis_per_day);
65-
// SAFETY: here we can convert i64 to N safely since we determine that the type N is i64
66-
unsafe {
67-
std::ptr::read(&adjusted_value as *const i64 as *const N)
61+
DataType::Date64 => {
62+
// TODO: constrain this range to valid dates if necessary
63+
let date_value = self.rng.gen_range(i64::MIN..=i64::MAX);
64+
let millis_per_day: i64 = 86_400_000;
65+
let adjusted_value = date_value - (date_value % millis_per_day);
66+
// SAFETY: here we can convert i64 to N safely since we determine that the type N is i64
67+
unsafe {
68+
std::ptr::read(&adjusted_value as *const i64 as *const N)
69+
}
6870
}
69-
}
7071

71-
_ => {
72-
let arrow_type = A::DATA_TYPE;
73-
panic!("Unsupported arrow data type: {arrow_type}")
74-
}
75-
}))
72+
_ => {
73+
let arrow_type = A::DATA_TYPE;
74+
panic!("Unsupported arrow data type: {arrow_type}")
75+
}
76+
})
77+
})
7678
.collect();
7779

7880
// pick num_primitves randomly from the distinct string table

0 commit comments

Comments
 (0)