mapleFU opened a new issue, #44541: URL: https://github.com/apache/arrow/issues/44541
### Describe the bug, including details regarding any error messages, version, and platform. The problem raised from [1]. `NumericArray<T>` uses `values_` as a cache of typed values[2]. This might not being set when calling the `PrimitiveArray::PrimitiveArray` constructor [3]. The code can be reproduced like: ```c++ TEST(TestPrettyPrintArray, TimestampArray) { auto array = std::make_shared<TimestampArray>( timestamp(TimeUnit::MICRO), /*length=*/1, Buffer::FromVector(std::vector<int64_t>{0})); auto v0 = array->GetView(0); std::cout << v0 << std::endl; } ``` This might be fixed with: ```diff diff --git a/cpp/src/arrow/array/array_primitive.h b/cpp/src/arrow/array/array_primitive.h index 3e2893b7dd..410e8516da 100644 --- a/cpp/src/arrow/array/array_primitive.h +++ b/cpp/src/arrow/array/array_primitive.h @@ -103,6 +103,15 @@ class NumericArray : public PrimitiveArray { null_count, offset)); } + NumericArray(const std::shared_ptr<DataType>& type, int64_t length, + const std::shared_ptr<Buffer>& data, + const std::shared_ptr<Buffer>& null_bitmap = NULLPTR, + int64_t null_count = kUnknownNullCount, int64_t offset = 0): PrimitiveArray(type, length, data, null_bitmap, null_count, offset) { + values_ = raw_values_ + ? (reinterpret_cast<const value_type*>(raw_values_) + data_->offset) + : NULLPTR; + } + const value_type* raw_values() const { return values_; } value_type Value(int64_t i) const { return values_[i]; } ``` But I don't know would I missed something. [1] https://github.com/apache/arrow/pull/44190 [2] https://github.com/apache/arrow/blob/a3c39ecb778188539c3ec4b6c6f2b540d8e4be40/cpp/src/arrow/array/array_primitive.h#L131 [3] https://github.com/apache/arrow/blob/a3c39ecb778188539c3ec4b6c6f2b540d8e4be40/cpp/src/arrow/array/array_primitive.h#L122 ### Component(s) C++ -- 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: issues-unsubscr...@arrow.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org