diff --git a/datafusion/functions-aggregate/src/kurtosis.rs b/datafusion/functions-aggregate/src/kurtosis.rs index 9a9f142b38ad..f18f9c3921ad 100644 --- a/datafusion/functions-aggregate/src/kurtosis.rs +++ b/datafusion/functions-aggregate/src/kurtosis.rs @@ -155,7 +155,7 @@ impl Accumulator for KurtosisAccumulator { } fn evaluate(&mut self) -> datafusion_common::Result { - if self.count < 3 { + if self.count <= 3 { return Ok(ScalarValue::Float64(None)); } diff --git a/datafusion/sqllogictest/test_files/aggregate.slt b/datafusion/sqllogictest/test_files/aggregate.slt index e82f685ef7e1..7b095f369e95 100644 --- a/datafusion/sqllogictest/test_files/aggregate.slt +++ b/datafusion/sqllogictest/test_files/aggregate.slt @@ -5934,7 +5934,7 @@ SELECT kurtosis(col) FROM VALUES (1), (10), (100), (10), (1) as tab(col); query R SELECT kurtosis(col) FROM VALUES (1), (2), (3), (2), (1) as tab(col); ---- --0.615384615385 +-0.612244897959 query R SELECT kurtosis(col) FROM VALUES (1.0), (10.0), (100.0), (10.0), (1.0) as tab(col); @@ -5951,6 +5951,16 @@ SELECT kurtosis(col) FROM VALUES (1.0) as tab(col); ---- NULL +query R +SELECT kurtosis(col) FROM VALUES (1.0), (2.0) as tab(col); +---- +NULL + +query R +SELECT kurtosis(col) FROM VALUES (1.0), (2.0), (3.0) as tab(col); +---- +NULL + query R SELECT kurtosis(1); ----