Add null check for VarianceAggregatorCollector

This commit is contained in:
Adarsh Sanjeev 2023-12-04 22:26:44 +05:30 committed by GitHub
parent ddeb55fac1
commit ddd2299272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -91,8 +91,11 @@ public class VarianceAggregatorCollector
this.sum += other.sum;
}
static Object combineValues(Object lhs, @Nullable Object rhs)
static Object combineValues(@Nullable Object lhs, @Nullable Object rhs)
{
if (lhs == null) {
return rhs;
}
((VarianceAggregatorCollector) lhs).fold((VarianceAggregatorCollector) rhs);
return lhs;
}

View File

@ -173,6 +173,14 @@ public class VarianceAggregatorCollectorTest extends InitializedNullHandlingTest
Assert.assertEquals(0, VarianceAggregatorCollector.COMPARATOR.compare(v1, v2));
}
@Test
public void testNullCollectors()
{
VarianceAggregatorCollector collector =
(VarianceAggregatorCollector) VarianceAggregatorCollector.combineValues(null, null);
Assert.assertNull(collector);
}
private static class FloatHandOver extends TestFloatColumnSelector
{
float v;