@@ -361,9 +361,20 @@ void NumericArray<T>::PostConstruct(const ObjectMeta& meta) {
361361 } else {
362362 data_type = type_name_to_arrow_type (this ->data_type_ );
363363 }
364+
365+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
366+ // use the factory method as the constructor is protected since 20.0.0
367+ auto data = arrow::ArrayData::Make (
368+ data_type, this ->length_ ,
369+ {this ->null_bitmap_ ->ArrowBuffer (), this ->buffer_ ->ArrowBufferOrEmpty ()},
370+ this ->null_count_ , this ->offset_ );
371+ this ->array_ = std::static_pointer_cast<ArrayType>(arrow::MakeArray (data));
372+ #else
373+ // use the constructor
364374 this ->array_ = std::make_shared<ArrayType>(
365375 data_type, this ->length_ , this ->buffer_ ->ArrowBufferOrEmpty (),
366376 this ->null_bitmap_ ->ArrowBuffer (), this ->null_count_ , this ->offset_ );
377+ #endif
367378}
368379
369380template class NumericArray <int8_t >;
@@ -584,10 +595,18 @@ template class FixedNumericArrayBuilder<arrow::Time64Type>;
584595template class FixedNumericArrayBuilder <arrow::TimestampType>;
585596
586597void BooleanArray::PostConstruct (const ObjectMeta& meta) {
598+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
599+ auto data = arrow::ArrayData::Make (
600+ ConvertToArrowType<bool >::TypeValue (), this ->length_ ,
601+ {this ->null_bitmap_ ->ArrowBuffer (), this ->buffer_ ->ArrowBufferOrEmpty ()},
602+ this ->null_count_ , this ->offset_ );
603+ this ->array_ = std::static_pointer_cast<ArrayType>(arrow::MakeArray (data));
604+ #else
587605 this ->array_ = std::make_shared<ArrayType>(
588606 ConvertToArrowType<bool >::TypeValue (), this ->length_ ,
589607 this ->buffer_ ->ArrowBufferOrEmpty (), this ->null_bitmap_ ->ArrowBuffer (),
590608 this ->null_count_ , this ->offset_ );
609+ #endif
591610}
592611
593612BooleanArrayBuilder::BooleanArrayBuilder (Client& client)
@@ -642,10 +661,33 @@ Status BooleanArrayBuilder::Build(Client& client) {
642661
643662template <typename ArrayType>
644663void BaseBinaryArray<ArrayType>::PostConstruct(const ObjectMeta& meta) {
664+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
665+ std::shared_ptr<arrow::DataType> data_type;
666+ if constexpr (std::is_same_v<ArrayType, arrow::StringArray>) {
667+ data_type = arrow::utf8 ();
668+ } else if constexpr (std::is_same_v<ArrayType, arrow::LargeStringArray>) {
669+ data_type = arrow::large_utf8 ();
670+ } else if constexpr (std::is_same_v<ArrayType, arrow::BinaryArray>) {
671+ data_type = arrow::binary ();
672+ } else if constexpr (std::is_same_v<ArrayType, arrow::LargeBinaryArray>) {
673+ data_type = arrow::large_binary ();
674+ } else {
675+ VINEYARD_ASSERT (false , " Unsupported array type: " +
676+ std::to_string (ArrayType::type_id ()));
677+ }
678+ auto data =
679+ arrow::ArrayData::Make (data_type, this ->length_ ,
680+ {this ->null_bitmap_ ->ArrowBuffer (),
681+ this ->buffer_offsets_ ->ArrowBufferOrEmpty (),
682+ this ->buffer_data_ ->ArrowBufferOrEmpty ()},
683+ this ->null_count_ , this ->offset_ );
684+ this ->array_ = std::static_pointer_cast<ArrayType>(arrow::MakeArray (data));
685+ #else
645686 this ->array_ = std::make_shared<ArrayType>(
646687 this ->length_ , this ->buffer_offsets_ ->ArrowBufferOrEmpty (),
647688 this ->buffer_data_ ->ArrowBufferOrEmpty (),
648689 this ->null_bitmap_ ->ArrowBuffer (), this ->null_count_ , this ->offset_ );
690+ #endif
649691}
650692
651693template class BaseBinaryArray <arrow::BinaryArray>;
@@ -722,10 +764,19 @@ template class GenericBinaryArrayBuilder<arrow::LargeStringArray,
722764 arrow::LargeStringBuilder>;
723765
724766void FixedSizeBinaryArray::PostConstruct (const ObjectMeta& meta) {
767+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
768+ auto data = arrow::ArrayData::Make (
769+ arrow::fixed_size_binary (this ->byte_width_ ), this ->length_ ,
770+ {this ->null_bitmap_ ->ArrowBuffer (), this ->buffer_ ->ArrowBufferOrEmpty ()},
771+ this ->null_count_ , this ->offset_ );
772+ this ->array_ = std::static_pointer_cast<arrow::FixedSizeBinaryArray>(
773+ arrow::MakeArray (data));
774+ #else
725775 this ->array_ = std::make_shared<arrow::FixedSizeBinaryArray>(
726776 arrow::fixed_size_binary (this ->byte_width_ ), this ->length_ ,
727777 this ->buffer_ ->ArrowBufferOrEmpty (), this ->null_bitmap_ ->ArrowBuffer (),
728778 this ->null_count_ , this ->offset_ );
779+ #endif
729780}
730781
731782FixedSizeBinaryArrayBuilder::FixedSizeBinaryArrayBuilder (
@@ -784,7 +835,13 @@ Status FixedSizeBinaryArrayBuilder::Build(Client& client) {
784835}
785836
786837void NullArray::PostConstruct (const ObjectMeta& meta) {
838+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
839+ auto data = arrow::ArrayData::Make (arrow::null (), this ->length_ , {}, 0 );
840+ this ->array_ =
841+ std::static_pointer_cast<arrow::NullArray>(arrow::MakeArray (data));
842+ #else
787843 this ->array_ = std::make_shared<arrow::NullArray>(this ->length_ );
844+ #endif
788845}
789846
790847NullArrayBuilder::NullArrayBuilder (Client& client)
@@ -831,10 +888,19 @@ void BaseListArray<ArrayType>::PostConstruct(const ObjectMeta& meta) {
831888 auto array = detail::CastToArray (values_);
832889 auto list_type =
833890 std::make_shared<typename ArrayType::TypeClass>(array->type ());
891+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
892+ auto data =
893+ arrow::ArrayData::Make (list_type, this ->length_ ,
894+ {this ->null_bitmap_ ->ArrowBuffer (),
895+ this ->buffer_offsets_ ->ArrowBufferOrEmpty ()},
896+ {array->data ()}, this ->null_count_ , this ->offset_ );
897+ this ->array_ = std::static_pointer_cast<ArrayType>(arrow::MakeArray (data));
898+ #else
834899 this ->array_ = std::make_shared<ArrayType>(
835900 list_type, this ->length_ , this ->buffer_offsets_ ->ArrowBufferOrEmpty (),
836901 array, this ->null_bitmap_ ->ArrowBuffer (), this ->null_count_ ,
837902 this ->offset_ );
903+ #endif
838904}
839905
840906template class BaseListArray <arrow::ListArray>;
@@ -920,9 +986,18 @@ template class BaseListArrayBuilder<arrow::LargeListArray>;
920986
921987void FixedSizeListArray::PostConstruct (const ObjectMeta& meta) {
922988 auto array = detail::CastToArray (values_);
989+ #if defined(ARROW_VERSION) && ARROW_VERSION >= 20000000
990+ auto list_type = arrow::fixed_size_list (array->type (), this ->list_size_ );
991+
992+ auto data = arrow::ArrayData::Make (list_type, this ->length_ , {nullptr },
993+ {array->data ()}, 0 , 0 );
994+ this ->array_ = std::static_pointer_cast<arrow::FixedSizeListArray>(
995+ arrow::MakeArray (data));
996+ #else
923997 this ->array_ = std::make_shared<arrow::FixedSizeListArray>(
924998 arrow::fixed_size_list (array->type (), this ->list_size_ ), this ->length_ ,
925999 array);
1000+ #endif
9261001}
9271002
9281003FixedSizeListArrayBuilder::FixedSizeListArrayBuilder (
0 commit comments