MCPcopy Create free account
hub / github.com/apache/arrow / TestMergeMinMax

Method TestMergeMinMax

cpp/src/parquet/statistics_test.cc:706–743  ·  view source on GitHub ↗

If all values in a page are null or nan, its stats should not set min-max. Merging its stats with another page having good min-max stats should not drop the valid min-max from the latter page.

Source from the content-addressed store, hash-verified

704 // Merging its stats with another page having good min-max stats should not
705 // drop the valid min-max from the latter page.
706 void TestMergeMinMax() {
707 this->GenerateData(1000);
708 // Create a statistics object without min-max.
709 std::shared_ptr<TypedStatistics<TestType>> statistics1;
710 {
711 statistics1 = MakeStatistics<TestType>(this->schema_.Column(0));
712 statistics1->Update(this->values_ptr_, /*num_values=*/0,
713 /*null_count=*/this->values_.size());
714 auto encoded_stats1 = statistics1->Encode();
715 EXPECT_FALSE(statistics1->HasMinMax());
716 EXPECT_FALSE(encoded_stats1.has_min);
717 EXPECT_FALSE(encoded_stats1.has_max);
718 EXPECT_EQ(encoded_stats1.is_max_value_exact, std::nullopt);
719 EXPECT_EQ(encoded_stats1.is_min_value_exact, std::nullopt);
720 }
721 // Create a statistics object with min-max.
722 std::shared_ptr<TypedStatistics<TestType>> statistics2;
723 {
724 statistics2 = MakeStatistics<TestType>(this->schema_.Column(0));
725 statistics2->Update(this->values_ptr_, this->values_.size(), 0);
726 auto encoded_stats2 = statistics2->Encode();
727 EXPECT_TRUE(statistics2->HasMinMax());
728 EXPECT_TRUE(encoded_stats2.has_min);
729 EXPECT_TRUE(encoded_stats2.has_max);
730 EXPECT_EQ(encoded_stats2.is_min_value_exact, std::make_optional(true));
731 EXPECT_EQ(encoded_stats2.is_max_value_exact, std::make_optional(true));
732 }
733 VerifyMergedStatistics(*statistics1, *statistics2,
734 [](TypedStatistics<TestType>* merged_statistics) {
735 EXPECT_TRUE(merged_statistics->HasMinMax());
736 EXPECT_TRUE(merged_statistics->Encode().has_min);
737 EXPECT_TRUE(merged_statistics->Encode().has_max);
738 EXPECT_EQ(merged_statistics->Encode().is_min_value_exact,
739 std::make_optional(true));
740 EXPECT_EQ(merged_statistics->Encode().is_max_value_exact,
741 std::make_optional(true));
742 });
743 }
744
745 // Default statistics should have null_count even if no nulls is written.
746 // However, if statistics is created from thrift message, it might not

Callers 1

TYPED_TESTFunction · 0.80

Calls 6

HasMinMaxMethod · 0.80
GenerateDataMethod · 0.45
ColumnMethod · 0.45
UpdateMethod · 0.45
sizeMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected