@@ -152,6 +152,37 @@ TEST(TestValidityKernels, IsNullSetsZeroNullCount) {
152152 ASSERT_EQ (out.array ()->null_count , 0 );
153153}
154154
155+ TEST (TestValidityKernels, IsNullDictionaryNanIsNull) {
156+ NullOptions default_options;
157+ NullOptions nan_is_null_options (/* nan_is_null=*/ true );
158+
159+ auto dict_ty = dictionary (int32 (), float64 ());
160+ auto arr = DictArrayFromJSON (dict_ty, " [0, 1, 2, null, 1]" , " [1.5, NaN, -0.0]" );
161+
162+ // Without nan_is_null, dictionary-encoded NaNs are not treated as null.
163+ CheckScalarUnary (" is_null" , arr,
164+ ArrayFromJSON (boolean (), " [false, false, false, true, false]" ));
165+ CheckScalarUnary (" is_null" , arr,
166+ ArrayFromJSON (boolean (), " [false, false, false, true, false]" ),
167+ &default_options);
168+
169+ // With nan_is_null, the dictionary entry backing index 1 is NaN, so every
170+ // slot referencing it is null; the pre-existing null index stays null.
171+ CheckScalarUnary (" is_null" , arr,
172+ ArrayFromJSON (boolean (), " [false, true, false, true, true]" ),
173+ &nan_is_null_options);
174+ }
175+
176+ TEST (TestValidityKernels, IsNullDictionaryNanIsNullHalfFloat) {
177+ NullOptions nan_is_null_options (/* nan_is_null=*/ true );
178+
179+ auto dict_ty = dictionary (int8 (), float16 ());
180+ auto arr = DictArrayFromJSON (dict_ty, " [0, 1]" , " [1.5, NaN]" );
181+
182+ CheckScalarUnary (" is_null" , arr, ArrayFromJSON (boolean (), " [false, true]" ),
183+ &nan_is_null_options);
184+ }
185+
155186template <typename ArrowType>
156187class TestFloatingPointValidityKernels : public TestValidityKernels <ArrowType> {
157188 public:
0 commit comments