Skip to content

Commit

Permalink
Add support for CopyTo
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Aug 30, 2024
1 parent ea16740 commit 942f757
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cpp/src/arrow/array/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3812,6 +3812,24 @@ TEST_F(TestArrayDataStatistics, CopyAssignment) {
ASSERT_TRUE(copied_data.statistics->is_max_exact);
}

TEST_F(TestArrayDataStatistics, CopyTo) {
ASSERT_OK_AND_ASSIGN(auto copied_data,
data_->CopyTo(arrow::default_cpu_memory_manager()));

ASSERT_TRUE(copied_data->statistics->null_count.has_value());
ASSERT_EQ(null_count_, copied_data->statistics->null_count.value());

ASSERT_TRUE(copied_data->statistics->min.has_value());
ASSERT_TRUE(std::holds_alternative<int64_t>(copied_data->statistics->min.value()));
ASSERT_EQ(min_, std::get<int64_t>(copied_data->statistics->min.value()));
ASSERT_TRUE(copied_data->statistics->is_min_exact);

ASSERT_TRUE(copied_data->statistics->max.has_value());
ASSERT_TRUE(std::holds_alternative<int64_t>(copied_data->statistics->max.value()));
ASSERT_EQ(max_, std::get<int64_t>(copied_data->statistics->max.value()));
ASSERT_TRUE(copied_data->statistics->is_max_exact);
}

TEST_F(TestArrayDataStatistics, Slice) {
auto sliced_data = data_->Slice(0, 1);
ASSERT_FALSE(sliced_data->statistics);
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/arrow/array/data.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ Result<std::shared_ptr<ArrayData>> CopyToImpl(const ArrayData& data,
ARROW_ASSIGN_OR_RAISE(output->dictionary, CopyToImpl(*data.dictionary, to, copy_fn));
}

output->statistics = data.statistics;

return output;
}
} // namespace
Expand Down

0 comments on commit 942f757

Please sign in to comment.