This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 5657886121 Remove unnecessary qualified names (#11292)
5657886121 is described below
commit 5657886121e5cec4d53d39d6771427c1dd3f910f
Author: Piotr Findeisen <[email protected]>
AuthorDate: Sat Jul 6 13:10:03 2024 +0200
Remove unnecessary qualified names (#11292)
Leverage existing imports.
---
datafusion-examples/examples/advanced_udaf.rs | 2 +-
.../functions-aggregate/src/approx_distinct.rs | 2 +-
.../src/approx_percentile_cont.rs | 2 +-
datafusion/functions-aggregate/src/average.rs | 2 +-
.../functions-aggregate/src/bit_and_or_xor.rs | 8 +-
datafusion/functions-aggregate/src/count.rs | 20 +++--
datafusion/physical-expr-common/src/binary_map.rs | 4 +-
.../physical-expr-common/src/expressions/cast.rs | 89 ++++++++++------------
datafusion/physical-expr/src/expressions/case.rs | 2 +-
9 files changed, 62 insertions(+), 69 deletions(-)
diff --git a/datafusion-examples/examples/advanced_udaf.rs
b/datafusion-examples/examples/advanced_udaf.rs
index 2c672a18a7..48da09a512 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<Vec<arrow_schema::Field>> {
+ fn state_fields(&self, args: StateFieldsArgs) -> Result<Vec<Field>> {
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 6f1e97a163..7c6aef9944 100644
--- a/datafusion/functions-aggregate/src/approx_distinct.rs
+++ b/datafusion/functions-aggregate/src/approx_distinct.rs
@@ -211,7 +211,7 @@ where
impl<T> Accumulator for NumericHLLAccumulator<T>
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 5ae5684d9c..bbe7d21e24 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 1dc1f10afc..18642fb843 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::<datafusion_common::Result<Vec<_>>>()?;
+ .collect::<Result<Vec<_>>>()?;
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 ba99642704..9224b06e40 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<T: ArrowNumericType> {
}
impl<T: ArrowNumericType> std::fmt::Debug for BitAndAccumulator<T> {
- 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<T: ArrowNumericType> {
}
impl<T: ArrowNumericType> std::fmt::Debug for BitOrAccumulator<T> {
- 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<T: ArrowNumericType> {
}
impl<T: ArrowNumericType> std::fmt::Debug for BitXorAccumulator<T> {
- 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<T: ArrowNumericType> {
}
impl<T: ArrowNumericType> std::fmt::Debug for DistinctBitXorAccumulator<T> {
- 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 0fc8e32d72..bd0155df02 100644
--- a/datafusion/functions-aggregate/src/count.rs
+++ b/datafusion/functions-aggregate/src/count.rs
@@ -62,17 +62,15 @@ make_udaf_expr_and_func!(
count_udaf
);
-pub fn count_distinct(expr: Expr) -> datafusion_expr::Expr {
- datafusion_expr::Expr::AggregateFunction(
- datafusion_expr::expr::AggregateFunction::new_udf(
- count_udaf(),
- vec![expr],
- true,
- None,
- None,
- None,
- ),
- )
+pub fn count_distinct(expr: Expr) -> Expr {
+ Expr::AggregateFunction(datafusion_expr::expr::AggregateFunction::new_udf(
+ count_udaf(),
+ vec![expr],
+ true,
+ None,
+ None,
+ None,
+ ))
}
pub struct Count {
diff --git a/datafusion/physical-expr-common/src/binary_map.rs
b/datafusion/physical-expr-common/src/binary_map.rs
index 6d5ba737a1..bff571f5b5 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::<u8>()
+ + self.buffer.capacity() * mem::size_of::<u8>()
+ 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 31b96889fd..8aba33932c 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,10 @@ 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)?;
+ let expression = cast_with_options(col("a", &schema)?, &schema, Int32,
None)?;
let result = expression.evaluate(&batch);
match result {
@@ -717,15 +716,11 @@ 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),
- None,
- )?;
+ let expression =
+ cast_with_options(col("a", &schema)?, &schema, Decimal128(38, 38),
None)?;
expression.evaluate(&batch)?;
Ok(())
}
diff --git a/datafusion/physical-expr/src/expressions/case.rs
b/datafusion/physical-expr/src/expressions/case.rs
index b1707d3abf..cd73c5cb57 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(())
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]