@@ -1841,6 +1841,24 @@ class TestPrimitiveMinMaxKernel : public ::testing::Test {
18411841 AssertMinMaxIsNull (array, options);
18421842 }
18431843
1844+ void AssertMinMaxIsNaN (const Datum& array, const ScalarAggregateOptions& options) {
1845+ ASSERT_OK_AND_ASSIGN (Datum out, MinMax (array, options));
1846+ for (const auto & val : out.scalar_as <StructScalar>().value ) {
1847+ ASSERT_TRUE (std::isnan (checked_cast<const ScalarType&>(*val).value ));
1848+ }
1849+ }
1850+
1851+ void AssertMinMaxIsNaN (const std::string& json, const ScalarAggregateOptions& options) {
1852+ auto array = ArrayFromJSON (type_singleton (), json);
1853+ AssertMinMaxIsNaN (array, options);
1854+ }
1855+
1856+ void AssertMinMaxIsNaN (const std::vector<std::string>& json,
1857+ const ScalarAggregateOptions& options) {
1858+ auto array = ChunkedArrayFromJSON (type_singleton (), json);
1859+ AssertMinMaxIsNaN (array, options);
1860+ }
1861+
18441862 std::shared_ptr<DataType> type_singleton () {
18451863 return default_type_instance<ArrowType>();
18461864 }
@@ -1963,6 +1981,9 @@ TYPED_TEST(TestFloatingMinMaxKernel, Floats) {
19631981 this ->AssertMinMaxIs (" [5, Inf, 2, 3, 4]" , 2.0 , INFINITY, options);
19641982 this ->AssertMinMaxIs (" [5, NaN, 2, 3, 4]" , 2 , 5 , options);
19651983 this ->AssertMinMaxIs (" [5, -Inf, 2, 3, 4]" , -INFINITY, 5 , options);
1984+ this ->AssertMinMaxIs (" [NaN, null, 42]" , 42 , 42 , options);
1985+ this ->AssertMinMaxIsNaN (" [NaN, NaN]" , options);
1986+ this ->AssertMinMaxIsNaN (" [NaN, null]" , options);
19661987 this ->AssertMinMaxIs (chunked_input1, 1 , 9 , options);
19671988 this ->AssertMinMaxIs (chunked_input2, 1 , 9 , options);
19681989 this ->AssertMinMaxIs (chunked_input3, 1 , 9 , options);
@@ -1980,6 +2001,7 @@ TYPED_TEST(TestFloatingMinMaxKernel, Floats) {
19802001 this ->AssertMinMaxIs (" [5, -Inf, 2, 3, 4]" , -INFINITY, 5 , options);
19812002 this ->AssertMinMaxIsNull (" [5, null, 2, 3, 4]" , options);
19822003 this ->AssertMinMaxIsNull (" [5, -Inf, null, 3, 4]" , options);
2004+ this ->AssertMinMaxIsNull (" [NaN, null]" , options);
19832005 this ->AssertMinMaxIsNull (chunked_input1, options);
19842006 this ->AssertMinMaxIsNull (chunked_input2, options);
19852007 this ->AssertMinMaxIsNull (chunked_input3, options);
0 commit comments