diff --git a/datafusion-examples/examples/advanced_udaf.rs b/datafusion-examples/examples/advanced_udaf.rs index 2c672a18a738e..48da09a512367 100644 --- a/datafusion-examples/examples/advanced_udaf.rs +++ b/datafusion-examples/examples/advanced_udaf.rs @@ -92,7 +92,7 @@ impl AggregateUDFImpl for GeoMeanUdaf { } /// This is the description of the state. accumulator's state() must match the types here. - fn state_fields(&self, args: StateFieldsArgs) -> Result> { + fn state_fields(&self, args: StateFieldsArgs) -> Result> { Ok(vec![ Field::new("prod", args.return_type.clone(), true), Field::new("n", DataType::UInt32, true), diff --git a/datafusion/functions-aggregate/src/approx_distinct.rs b/datafusion/functions-aggregate/src/approx_distinct.rs index 6f1e97a163806..7c6aef9944f69 100644 --- a/datafusion/functions-aggregate/src/approx_distinct.rs +++ b/datafusion/functions-aggregate/src/approx_distinct.rs @@ -211,7 +211,7 @@ where impl Accumulator for NumericHLLAccumulator where - T: ArrowPrimitiveType + std::fmt::Debug, + T: ArrowPrimitiveType + Debug, T::Native: Hash, { fn update_batch(&mut self, values: &[ArrayRef]) -> Result<()> { diff --git a/datafusion/functions-aggregate/src/approx_percentile_cont.rs b/datafusion/functions-aggregate/src/approx_percentile_cont.rs index 5ae5684d9cabc..bbe7d21e24866 100644 --- a/datafusion/functions-aggregate/src/approx_percentile_cont.rs +++ b/datafusion/functions-aggregate/src/approx_percentile_cont.rs @@ -191,7 +191,7 @@ impl AggregateUDFImpl for ApproxPercentileCont { } #[allow(rustdoc::private_intra_doc_links)] - /// See [`datafusion_physical_expr_common::aggregate::tdigest::TDigest::to_scalar_state()`] for a description of the serialised + /// See [`TDigest::to_scalar_state()`] for a description of the serialised /// state. fn state_fields( &self, diff --git a/datafusion/functions-aggregate/src/average.rs b/datafusion/functions-aggregate/src/average.rs index 1dc1f10afce62..18642fb843293 100644 --- a/datafusion/functions-aggregate/src/average.rs +++ b/datafusion/functions-aggregate/src/average.rs @@ -489,7 +489,7 @@ where .into_iter() .zip(counts.into_iter()) .map(|(sum, count)| (self.avg_fn)(sum, count)) - .collect::>>()?; + .collect::>>()?; PrimitiveArray::new(averages.into(), Some(nulls)) // no copy .with_data_type(self.return_data_type.clone()) }; diff --git a/datafusion/functions-aggregate/src/bit_and_or_xor.rs b/datafusion/functions-aggregate/src/bit_and_or_xor.rs index 19e24f547d8a8..0b3cbcc204901 100644 --- a/datafusion/functions-aggregate/src/bit_and_or_xor.rs +++ b/datafusion/functions-aggregate/src/bit_and_or_xor.rs @@ -245,7 +245,7 @@ struct BitAndAccumulator { } impl std::fmt::Debug for BitAndAccumulator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "BitAndAccumulator({})", T::DATA_TYPE) } } @@ -290,7 +290,7 @@ struct BitOrAccumulator { } impl std::fmt::Debug for BitOrAccumulator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "BitOrAccumulator({})", T::DATA_TYPE) } } @@ -335,7 +335,7 @@ struct BitXorAccumulator { } impl std::fmt::Debug for BitXorAccumulator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "BitXorAccumulator({})", T::DATA_TYPE) } } @@ -380,7 +380,7 @@ struct DistinctBitXorAccumulator { } impl std::fmt::Debug for DistinctBitXorAccumulator { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "DistinctBitXorAccumulator({})", T::DATA_TYPE) } } diff --git a/datafusion/functions-aggregate/src/count.rs b/datafusion/functions-aggregate/src/count.rs index 84abc0d730988..9644d2f04d73b 100644 --- a/datafusion/functions-aggregate/src/count.rs +++ b/datafusion/functions-aggregate/src/count.rs @@ -62,8 +62,8 @@ make_udaf_expr_and_func!( count_udaf ); -pub fn count_distinct(expr: Expr) -> datafusion_expr::Expr { - datafusion_expr::Expr::AggregateFunction( +pub fn count_distinct(expr: Expr) -> Expr { + Expr::AggregateFunction( datafusion_expr::expr::AggregateFunction::new_udf( count_udaf(), vec![expr], diff --git a/datafusion/physical-expr-common/src/binary_map.rs b/datafusion/physical-expr-common/src/binary_map.rs index 6d5ba737a1df5..bff571f5b5be1 100644 --- a/datafusion/physical-expr-common/src/binary_map.rs +++ b/datafusion/physical-expr-common/src/binary_map.rs @@ -255,7 +255,7 @@ where /// the same output type pub fn take(&mut self) -> Self { let mut new_self = Self::new(self.output_type); - std::mem::swap(self, &mut new_self); + mem::swap(self, &mut new_self); new_self } @@ -538,7 +538,7 @@ where /// this set, not including `self` pub fn size(&self) -> usize { self.map_size - + self.buffer.capacity() * std::mem::size_of::() + + self.buffer.capacity() * mem::size_of::() + self.offsets.allocated_size() + self.hashes_buffer.allocated_size() } diff --git a/datafusion/physical-expr-common/src/expressions/cast.rs b/datafusion/physical-expr-common/src/expressions/cast.rs index 31b96889fd62d..e13601540a445 100644 --- a/datafusion/physical-expr-common/src/expressions/cast.rs +++ b/datafusion/physical-expr-common/src/expressions/cast.rs @@ -366,9 +366,9 @@ mod tests { generic_decimal_to_other_test_cast!( decimal_array, - DataType::Decimal128(10, 3), + Decimal128(10, 3), Decimal128Array, - DataType::Decimal128(20, 6), + Decimal128(20, 6), [ Some(1_234_000), Some(2_222_000), @@ -387,9 +387,9 @@ mod tests { generic_decimal_to_other_test_cast!( decimal_array, - DataType::Decimal128(10, 3), + Decimal128(10, 3), Decimal128Array, - DataType::Decimal128(10, 2), + Decimal128(10, 2), [Some(123), Some(222), Some(0), Some(400), Some(500), None], None ); @@ -408,9 +408,9 @@ mod tests { .with_precision_and_scale(10, 0)?; generic_decimal_to_other_test_cast!( decimal_array, - DataType::Decimal128(10, 0), + Decimal128(10, 0), Int8Array, - DataType::Int8, + Int8, [ Some(1_i8), Some(2_i8), @@ -430,9 +430,9 @@ mod tests { .with_precision_and_scale(10, 0)?; generic_decimal_to_other_test_cast!( decimal_array, - DataType::Decimal128(10, 0), + Decimal128(10, 0), Int16Array, - DataType::Int16, + Int16, [ Some(1_i16), Some(2_i16), @@ -452,9 +452,9 @@ mod tests { .with_precision_and_scale(10, 0)?; generic_decimal_to_other_test_cast!( decimal_array, - DataType::Decimal128(10, 0), + Decimal128(10, 0), Int32Array, - DataType::Int32, + Int32, [ Some(1_i32), Some(2_i32), @@ -473,9 +473,9 @@ mod tests { .with_precision_and_scale(10, 0)?; generic_decimal_to_other_test_cast!( decimal_array, - DataType::Decimal128(10, 0), + Decimal128(10, 0), Int64Array, - DataType::Int64, + Int64, [ Some(1_i64), Some(2_i64), @@ -503,9 +503,9 @@ mod tests { .with_precision_and_scale(10, 3)?; generic_decimal_to_other_test_cast!( decimal_array, - DataType::Decimal128(10, 3), + Decimal128(10, 3), Float32Array, - DataType::Float32, + Float32, [ Some(1.234_f32), Some(2.222_f32), @@ -524,9 +524,9 @@ mod tests { .with_precision_and_scale(20, 6)?; generic_decimal_to_other_test_cast!( decimal_array, - DataType::Decimal128(20, 6), + Decimal128(20, 6), Float64Array, - DataType::Float64, + Float64, [ Some(0.001234_f64), Some(0.002222_f64), @@ -545,10 +545,10 @@ mod tests { // int8 generic_test_cast!( Int8Array, - DataType::Int8, + Int8, vec![1, 2, 3, 4, 5], Decimal128Array, - DataType::Decimal128(3, 0), + Decimal128(3, 0), [Some(1), Some(2), Some(3), Some(4), Some(5)], None ); @@ -556,10 +556,10 @@ mod tests { // int16 generic_test_cast!( Int16Array, - DataType::Int16, + Int16, vec![1, 2, 3, 4, 5], Decimal128Array, - DataType::Decimal128(5, 0), + Decimal128(5, 0), [Some(1), Some(2), Some(3), Some(4), Some(5)], None ); @@ -567,10 +567,10 @@ mod tests { // int32 generic_test_cast!( Int32Array, - DataType::Int32, + Int32, vec![1, 2, 3, 4, 5], Decimal128Array, - DataType::Decimal128(10, 0), + Decimal128(10, 0), [Some(1), Some(2), Some(3), Some(4), Some(5)], None ); @@ -578,10 +578,10 @@ mod tests { // int64 generic_test_cast!( Int64Array, - DataType::Int64, + Int64, vec![1, 2, 3, 4, 5], Decimal128Array, - DataType::Decimal128(20, 0), + Decimal128(20, 0), [Some(1), Some(2), Some(3), Some(4), Some(5)], None ); @@ -589,10 +589,10 @@ mod tests { // int64 to different scale generic_test_cast!( Int64Array, - DataType::Int64, + Int64, vec![1, 2, 3, 4, 5], Decimal128Array, - DataType::Decimal128(20, 2), + Decimal128(20, 2), [Some(100), Some(200), Some(300), Some(400), Some(500)], None ); @@ -600,10 +600,10 @@ mod tests { // float32 generic_test_cast!( Float32Array, - DataType::Float32, + Float32, vec![1.5, 2.5, 3.0, 1.123_456_8, 5.50], Decimal128Array, - DataType::Decimal128(10, 2), + Decimal128(10, 2), [Some(150), Some(250), Some(300), Some(112), Some(550)], None ); @@ -611,10 +611,10 @@ mod tests { // float64 generic_test_cast!( Float64Array, - DataType::Float64, + Float64, vec![1.5, 2.5, 3.0, 1.123_456_8, 5.50], Decimal128Array, - DataType::Decimal128(20, 4), + Decimal128(20, 4), [ Some(15000), Some(25000), @@ -631,10 +631,10 @@ mod tests { fn test_cast_i32_u32() -> Result<()> { generic_test_cast!( Int32Array, - DataType::Int32, + Int32, vec![1, 2, 3, 4, 5], UInt32Array, - DataType::UInt32, + UInt32, [ Some(1_u32), Some(2_u32), @@ -651,10 +651,10 @@ mod tests { fn test_cast_i32_utf8() -> Result<()> { generic_test_cast!( Int32Array, - DataType::Int32, + Int32, vec![1, 2, 3, 4, 5], StringArray, - DataType::Utf8, + Utf8, [Some("1"), Some("2"), Some("3"), Some("4"), Some("5")], None ); @@ -670,10 +670,10 @@ mod tests { .collect(); generic_test_cast!( Int64Array, - DataType::Int64, + Int64, original, TimestampNanosecondArray, - DataType::Timestamp(TimeUnit::Nanosecond, None), + Timestamp(TimeUnit::Nanosecond, None), expected, None ); @@ -683,7 +683,7 @@ mod tests { #[test] fn invalid_cast() { // Ensure a useful error happens at plan time if invalid casts are used - let schema = Schema::new(vec![Field::new("a", DataType::Int32, false)]); + let schema = Schema::new(vec![Field::new("a", Int32, false)]); let result = cast( col("a", &schema).unwrap(), @@ -696,11 +696,11 @@ mod tests { #[test] fn invalid_cast_with_options_error() -> Result<()> { // Ensure a useful error happens at plan time if invalid casts are used - let schema = Schema::new(vec![Field::new("a", DataType::Utf8, false)]); + let schema = Schema::new(vec![Field::new("a", Utf8, false)]); let a = StringArray::from(vec!["9.1"]); let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(a)])?; let expression = - cast_with_options(col("a", &schema)?, &schema, DataType::Int32, None)?; + cast_with_options(col("a", &schema)?, &schema, Int32, None)?; let result = expression.evaluate(&batch); match result { @@ -717,13 +717,13 @@ mod tests { #[test] #[ignore] // TODO: https://github.com/apache/datafusion/issues/5396 fn test_cast_decimal() -> Result<()> { - let schema = Schema::new(vec![Field::new("a", DataType::Int64, false)]); + let schema = Schema::new(vec![Field::new("a", Int64, false)]); let a = Int64Array::from(vec![100]); let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![Arc::new(a)])?; let expression = cast_with_options( col("a", &schema)?, &schema, - DataType::Decimal128(38, 38), + Decimal128(38, 38), None, )?; expression.evaluate(&batch)?; diff --git a/datafusion/physical-expr/src/expressions/case.rs b/datafusion/physical-expr/src/expressions/case.rs index 08d8cd4413347..66509036e0ba0 100644 --- a/datafusion/physical-expr/src/expressions/case.rs +++ b/datafusion/physical-expr/src/expressions/case.rs @@ -870,7 +870,7 @@ mod tests { ); assert!(expr.is_ok()); let result_type = expr.unwrap().data_type(schema.as_ref())?; - assert_eq!(DataType::Float64, result_type); + assert_eq!(Float64, result_type); Ok(()) }