Apache DataFusion SQL Query Engine
chore: move stddev test to slt (#10741)
Marvin Lanhenkea803214015ff
diff --git a/datafusion/physical-expr/src/aggregate/stddev.rs b/datafusion/physical-expr/src/aggregate/stddev.rsindex e5ce1b9230..ec8d8cea67 100644--- a/datafusion/physical-expr/src/aggregate/stddev.rs+++ b/datafusion/physical-expr/src/aggregate/stddev.rs@@ -245,135 +245,8 @@ mod tests {use super::*;use crate::aggregate::utils::get_accum_scalar_values_as_arrays;use crate::expressions::col;- use crate::expressions::tests::aggregate;- use crate::generic_test_op;use arrow::{array::*, datatypes::*};- #[test]- fn stddev_f64_1() -> Result<()> {- let a: ArrayRef = Arc::new(Float64Array::from(vec![1_f64, 2_f64]));- generic_test_op!(a, DataType::Float64, StddevPop, ScalarValue::from(0.5_f64))- }-- #[test]- fn stddev_f64_2() -> Result<()> {- let a: ArrayRef = Arc::new(Float64Array::from(vec![1.1_f64, 2_f64, 3_f64]));- generic_test_op!(- a,- DataType::Float64,- StddevPop,- ScalarValue::from(0.7760297817881877_f64)- )- }-- #[test]- fn stddev_f64_3() -> Result<()> {- let a: ArrayRef =- Arc::new(Float64Array::from(vec![1_f64, 2_f64, 3_f64, 4_f64, 5_f64]));- generic_test_op!(- a,- DataType::Float64,- StddevPop,- ScalarValue::from(std::f64::consts::SQRT_2)- )- }-- #[test]- fn stddev_f64_4() -> Result<()> {- let a: ArrayRef = Arc::new(Float64Array::from(vec![1.1_f64, 2_f64, 3_f64]));- generic_test_op!(- a,- DataType::Float64,- Stddev,- ScalarValue::from(0.9504384952922168_f64)- )- }-- #[test]- fn stddev_i32() -> Result<()> {- let a: ArrayRef = Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5]));- generic_test_op!(- a,- DataType::Int32,- StddevPop,- ScalarValue::from(std::f64::consts::SQRT_2)- )- }-- #[test]- fn stddev_u32() -> Result<()> {- let a: ArrayRef =- Arc::new(UInt32Array::from(vec![1_u32, 2_u32, 3_u32, 4_u32, 5_u32]));- generic_test_op!(- a,- DataType::UInt32,- StddevPop,- ScalarValue::from(std::f64::consts::SQRT_2)- )- }-- #[test]- fn stddev_f32() -> Result<()> {- let a: ArrayRef =- Arc::new(Float32Array::from(vec![1_f32, 2_f32, 3_f32, 4_f32, 5_f32]));- generic_test_op!(- a,- DataType::Float32,- StddevPop,- ScalarValue::from(std::f64::consts::SQRT_2)- )- }-- #[test]- fn test_stddev_1_input() -> Result<()> {- let a: ArrayRef = Arc::new(Float64Array::from(vec![1_f64]));- let schema = Schema::new(vec![Field::new("a", DataType::Float64, false)]);- let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![a])?;-- let agg = Arc::new(Stddev::new(- col("a", &schema)?,- "bla".to_string(),- DataType::Float64,- ));- let actual = aggregate(&batch, agg).unwrap();- assert_eq!(actual, ScalarValue::Float64(None));-- Ok(())- }-- #[test]- fn stddev_i32_with_nulls() -> Result<()> {- let a: ArrayRef = Arc::new(Int32Array::from(vec![- Some(1),- None,- Some(3),- Some(4),- Some(5),- ]));- generic_test_op!(- a,- DataType::Int32,- StddevPop,- ScalarValue::from(1.479019945774904_f64)- )- }-- #[test]- fn stddev_i32_all_nulls() -> Result<()> {- let a: ArrayRef = Arc::new(Int32Array::from(vec![None, None]));- let schema = Schema::new(vec![Field::new("a", DataType::Int32, true)]);- let batch = RecordBatch::try_new(Arc::new(schema.clone()), vec![a])?;-- let agg = Arc::new(Stddev::new(- col("a", &schema)?,- "bla".to_string(),- DataType::Float64,- ));- let actual = aggregate(&batch, agg).unwrap();- assert_eq!(actual, ScalarValue::Float64(None));- Ok(())- }-#[test]fn stddev_f64_merge_1() -> Result<()> {let a = Arc::new(Float64Array::from(vec![1_f64, 2_f64, 3_f64]));diff --git a/datafusion/sqllogictest/test_files/aggregate.slt b/datafusion/sqllogictest/test_files/aggregate.sltindex 256fddd9f2..03e8fad8a7 100644--- a/datafusion/sqllogictest/test_files/aggregate.slt+++ b/datafusion/sqllogictest/test_files/aggregate.slt@@ -2338,6 +2338,128 @@ select covar_pop(c1, c2), arrow_typeof(covar_pop(c1, c2)) from t;statement okdrop table t;+# aggregate stddev f64_1+statement ok+create table t (c1 double) as values (1), (2);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+0.5 Float64++statement ok+drop table t;++# aggregate stddev f64_2+statement ok+create table t (c1 double) as values (1.1), (2), (3);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+0.776029781788 Float64++statement ok+drop table t;++# aggregate stddev f64_3+statement ok+create table t (c1 double) as values (1), (2), (3), (4), (5);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+1.414213562373 Float64++statement ok+drop table t;++# aggregate stddev f64_4+statement ok+create table t (c1 double) as values (1.1), (2), (3);++query RT+select stddev(c1), arrow_typeof(stddev(c1)) from t;+----+0.950438495292 Float64++statement ok+drop table t;++# aggregate stddev i32+statement ok+create table t (c1 int) as values (1), (2), (3), (4), (5);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+1.414213562373 Float64++statement ok+drop table t;++# aggregate stddev u32+statement ok+create table t (c1 int unsigned) as values (1), (2), (3), (4), (5);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+1.414213562373 Float64++statement ok+drop table t;++# aggregate stddev f32+statement ok+create table t (c1 float) as values (1), (2), (3), (4), (5);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+1.414213562373 Float64++statement ok+drop table t;++# aggregate stddev single_input+statement ok+create table t (c1 double) as values (1);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+0 Float64++statement ok+drop table t;++# aggregate stddev with_nulls+statement ok+create table t (c1 int) as values (1), (null), (3), (4), (5);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+1.479019945775 Float64++statement ok+drop table t;++# aggregate stddev all_nulls+statement ok+create table t (c1 int) as values (null), (null);++query RT+select stddev_pop(c1), arrow_typeof(stddev_pop(c1)) from t;+----+NULL Float64++statement ok+drop table t;+++# simple_meanquery Rselect mean(c1) from test