Apache DataFusion SQL Query Engine
chore: move aggregate_var to slt (#10750)
Marvin Lanhenke1db326349753
diff --git a/datafusion/physical-expr/src/aggregate/variance.rs b/datafusion/physical-expr/src/aggregate/variance.rsindex 9890410977..7ae917409a 100644--- a/datafusion/physical-expr/src/aggregate/variance.rs+++ b/datafusion/physical-expr/src/aggregate/variance.rs@@ -337,117 +337,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 variance_f64_1() -> Result<()> {- let a: ArrayRef = Arc::new(Float64Array::from(vec![1_f64, 2_f64]));- generic_test_op!(- a,- DataType::Float64,- VariancePop,- ScalarValue::from(0.25_f64)- )- }-- #[test]- fn variance_f64_2() -> 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, VariancePop, ScalarValue::from(2_f64))- }-- #[test]- fn variance_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, Variance, ScalarValue::from(2.5_f64))- }-- #[test]- fn variance_f64_4() -> Result<()> {- let a: ArrayRef = Arc::new(Float64Array::from(vec![1.1_f64, 2_f64, 3_f64]));- generic_test_op!(- a,- DataType::Float64,- Variance,- ScalarValue::from(0.9033333333333333_f64)- )- }-- #[test]- fn variance_i32() -> Result<()> {- let a: ArrayRef = Arc::new(Int32Array::from(vec![1, 2, 3, 4, 5]));- generic_test_op!(a, DataType::Int32, VariancePop, ScalarValue::from(2_f64))- }-- #[test]- fn variance_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, VariancePop, ScalarValue::from(2.0f64))- }-- #[test]- fn variance_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, VariancePop, ScalarValue::from(2_f64))- }-- #[test]- fn test_variance_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(Variance::new(- col("a", &schema)?,- "bla".to_string(),- DataType::Float64,- ));- let actual = aggregate(&batch, agg).unwrap();- assert_eq!(actual, ScalarValue::Float64(None));-- Ok(())- }-- #[test]- fn variance_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,- VariancePop,- ScalarValue::from(2.1875_f64)- )- }-- #[test]- fn variance_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(Variance::new(- col("a", &schema)?,- "bla".to_string(),- DataType::Float64,- ));- let actual = aggregate(&batch, agg).unwrap();- assert_eq!(actual, ScalarValue::Float64(None));-- Ok(())- }-#[test]fn variance_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 03e8fad8a7..df6a376448 100644--- a/datafusion/sqllogictest/test_files/aggregate.slt+++ b/datafusion/sqllogictest/test_files/aggregate.slt@@ -2458,7 +2458,125 @@ NULL Float64statement okdrop table t;+# aggregate variance f64_1+statement ok+create table t (c1 double) as values (1), (2);++query RT+select var_pop(c1), arrow_typeof(var_pop(c1)) from t;+----+0.25 Float64++statement ok+drop table t;++# aggregate variance f64_2+statement ok+create table t (c1 double) as values (1), (2), (3), (4), (5);++query RT+select var_pop(c1), arrow_typeof(var_pop(c1)) from t;+----+2 Float64++statement ok+drop table t;++# aggregate variance f64_3+statement ok+create table t (c1 double) as values (1), (2), (3), (4), (5);++query RT+select var(c1), arrow_typeof(var(c1)) from t;+----+2.5 Float64+statement ok+drop table t;++# aggregate variance f64_4+statement ok+create table t (c1 double) as values (1.1), (2), (3);++query RT+select var(c1), arrow_typeof(var(c1)) from t;+----+0.903333333333 Float64++statement ok+drop table t;++# aggregate variance i32+statement ok+create table t (c1 int) as values (1), (2), (3), (4), (5);++query RT+select var_pop(c1), arrow_typeof(var_pop(c1)) from t;+----+2 Float64++statement ok+drop table t;++# aggregate variance u32+statement ok+create table t (c1 int unsigned) as values (1), (2), (3), (4), (5);++query RT+select var_pop(c1), arrow_typeof(var_pop(c1)) from t;+----+2 Float64++statement ok+drop table t;++# aggregate variance f32+statement ok+create table t (c1 float) as values (1), (2), (3), (4), (5);++query RT+select var_pop(c1), arrow_typeof(var_pop(c1)) from t;+----+2 Float64++statement ok+drop table t;++# aggregate single input+statement ok+create table t (c1 double) as values (1);++query RT+select var_pop(c1), arrow_typeof(var_pop(c1)) from t;+----+0 Float64++statement ok+drop table t;++# aggregate i32 with nulls+statement ok+create table t (c1 int) as values (1), (null), (3), (4), (5);++query RT+select var_pop(c1), arrow_typeof(var_pop(c1)) from t;+----+2.1875 Float64++statement ok+drop table t;++# aggregate i32 all nulls+statement ok+create table t (c1 int) as values (null), (null);++query RT+select var_pop(c1), arrow_typeof(var_pop(c1)) from t;+----+NULL Float64++statement ok+drop table t;# simple_meanquery R