andishgar commented on PR #51325: URL: https://github.com/apache/arrow/pull/51325#issuecomment-5768172534
@HuaHuaY @pitrou there seems to be a paradox in the run-end encode compute kernel. The comment below mentions that NaN values are not merged for nested types: https://github.com/apache/arrow/blob/5c2ff723410f0841b0ea1158d455bbfa23ff1ca9/cpp/src/arrow/compute/kernels/vector_run_end_encode.cc#L307-L308 For nested types, the following code shows that consecutive NaN values are not merged: ```c++ TEST(MyTest, Struct) { auto struct_type = struct_({field("a", float32())}); auto array = ArrayFromJSON(struct_type, R"([{"a":NaN},{"a":NaN}])"); Datum datum(array); auto result = RunEndEncode(datum).ValueOrDie().array_as<RunEndEncodedArray>(); ARROW_LOGGER_INFO("", result->ToString()); } ``` The result is: ```text -- run_ends: [ 1, 2 ] -- values: -- is_valid: all not null -- child 0 type: float [ nan, nan ] ``` However, for non-nested types, consecutive NaN values are merged: ```c++ TEST(MyTest, Float) { std::shared_ptr<Array> array; ArrayFromVector<FloatType>({NAN, NAN}, &array); Datum datum(array); auto result = RunEndEncode(datum).ValueOrDie().array_as<RunEndEncodedArray>(); ARROW_LOGGER_INFO("", result->ToString()); } ``` The result is: ```text -- run_ends: [ 2 ] -- values: [ nan ] ``` So it seems that the behavior differs between nested and non-nested types, despite the comment suggesting that NaN values should not be merged for nested types. Is this the expected behavior? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
