mapleFU commented on code in PR #43726: URL: https://github.com/apache/arrow/pull/43726#discussion_r1742088911
########## cpp/src/arrow/dataset/file_parquet_test.cc: ########## @@ -841,6 +841,53 @@ TEST(TestParquetStatistics, NullMax) { EXPECT_EQ(stat_expression->ToString(), "(x >= 1)"); } +TEST(TestParquetStatistics, NoNullCount) { + auto field = ::arrow::field("x", int32()); + auto parquet_node_ptr = ::parquet::schema::Int32("x", ::parquet::Repetition::REQUIRED); + ::parquet::ColumnDescriptor descr(parquet_node_ptr, /*max_definition_level=*/1, + /*max_repetition_level=*/0); + + auto int32_to_parquet_stats = [](int32_t v) { + std::string value; + value.resize(sizeof(int32_t)); + memcpy(value.data(), &v, sizeof(int32_t)); + return value; + }; + { + // Base case: when null_count is not set, the expression might contain null + ::parquet::EncodedStatistics encoded_stats; + encoded_stats.set_min(int32_to_parquet_stats(1)); + encoded_stats.set_max(int32_to_parquet_stats(100)); + encoded_stats.has_null_count = false; + encoded_stats.all_null_value = false; + encoded_stats.null_count = 0; + auto stats = ::parquet::Statistics::Make(&descr, &encoded_stats, /*num_values=*/10); + + auto stat_expression = + ParquetFileFragment::EvaluateStatisticsAsExpression(*field, *stats); + EXPECT_EQ(stat_expression->ToString(), + "(((x >= 1) and (x <= 100)) or is_null(x, {nan_is_null=false}))"); + } + { + // Special case: when num_value is 0, if has_null, it would return + // "is_null", otherwise it cannot gurantees anything Review Comment: Replied in https://github.com/apache/arrow/pull/43726/files#r1742087940 . I can also change to `is_null`. I've no trending here -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org