diff --git a/java/src/main/java/ai/rapids/cudf/RollingAggregation.java b/java/src/main/java/ai/rapids/cudf/RollingAggregation.java index 07983f77aad..408c93ff0a1 100644 --- a/java/src/main/java/ai/rapids/cudf/RollingAggregation.java +++ b/java/src/main/java/ai/rapids/cudf/RollingAggregation.java @@ -82,6 +82,19 @@ public static RollingAggregation max() { return new RollingAggregation(Aggregation.max()); } + /** + * Rolling Window Standard Deviation with 1 as delta degrees of freedom(DDOF). + */ + public static RollingAggregation standardDeviation() { + return new RollingAggregation(Aggregation.standardDeviation()); + } + + /** + * Rolling Window Standard Deviation with configurable delta degrees of freedom(DDOF). + */ + public static RollingAggregation standardDeviation(int ddof) { + return new RollingAggregation(Aggregation.standardDeviation(ddof)); + } /** * Count number of valid, a.k.a. non-null, elements. diff --git a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java index d1af0d9a2f6..c767a98b342 100644 --- a/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java +++ b/java/src/test/java/ai/rapids/cudf/ColumnVectorTest.java @@ -3085,6 +3085,17 @@ void testWindowStatic() { ColumnVector result = v1.rollingWindow(RollingAggregation.lag(1, defaultOutput), options)) { assertColumnsAreEqual(expected, result); } + + try (ColumnVector expected = ColumnVector.fromBoxedDoubles(0.7071d, 1.5275d, 1.5275d, 1d, 1.4142); + ColumnVector result = v1.rollingWindow(RollingAggregation.standardDeviation(), options)) { + assertColumnsAreEqual(expected, result); + } + + try (ColumnVector expected = + ColumnVector.fromBoxedDoubles(Double.POSITIVE_INFINITY, 2.1602d, 2.1602d, 1.4142d, Double.POSITIVE_INFINITY); + ColumnVector result = v1.rollingWindow(RollingAggregation.standardDeviation(2), options)) { + assertColumnsAreEqual(expected, result); + } } } }