2626#include " arrow/util/checked_cast.h"
2727#include " arrow/util/decimal.h"
2828#include " paimon/common/data/columnar/columnar_array.h"
29+ #include " paimon/common/data/columnar/columnar_batch_context.h"
2930#include " paimon/common/data/columnar/columnar_map.h"
31+ #include " paimon/common/data/columnar/columnar_row_ref.h"
3032#include " paimon/common/utils/date_time_utils.h"
3133
3234namespace paimon {
@@ -35,8 +37,11 @@ Decimal ColumnarRow::GetDecimal(int32_t pos, int32_t precision, int32_t scale) c
3537 auto array = arrow::internal::checked_cast<const ArrayType*>(array_vec_[pos]);
3638 assert (array);
3739 arrow::Decimal128 decimal (array->GetValue (row_id_));
38- return Decimal (precision, scale,
39- static_cast <Decimal::int128_t >(decimal.high_bits ()) << 64 | decimal.low_bits ());
40+ return Decimal (
41+ precision, scale,
42+ static_cast <Decimal::int128_t >(
43+ static_cast <Decimal::uint128_t >(static_cast <uint64_t >(decimal.high_bits ())) << 64 |
44+ decimal.low_bits ()));
4045}
4146
4247Timestamp ColumnarRow::GetTimestamp (int32_t pos, int32_t precision) const {
@@ -57,6 +62,9 @@ Timestamp ColumnarRow::GetTimestamp(int32_t pos, int32_t precision) const {
5762std::shared_ptr<InternalRow> ColumnarRow::GetRow (int32_t pos, int32_t num_fields) const {
5863 auto struct_array = arrow::internal::checked_cast<const arrow::StructArray*>(array_vec_[pos]);
5964 assert (struct_array);
65+ // NOTE: For performance, the returned nested row does NOT hold shared ownership of the parent
66+ // StructArray. Callers must ensure the parent ColumnarRow (or its underlying RecordBatch)
67+ // outlives the returned row to avoid dangling pointers.
6068 return std::make_shared<ColumnarRow>(struct_array->fields (), pool_, row_id_);
6169}
6270
0 commit comments