SteNicholas commented on code in PR #418:
URL: https://github.com/apache/paimon-cpp/pull/418#discussion_r4214489514
##########
src/paimon/format/parquet/parquet_stats_extractor_test.cpp:
##########
@@ -362,4 +383,101 @@ TEST_F(ParquetStatsExtractorTest,
TestExtractStatsTimestampType) {
CheckStats(fields, data_str, expected_stats_str,
/*expect_row_count=*/1);
}
}
+
+TEST_F(ParquetStatsExtractorTest, TestWrittenFileStatsAcrossRowGroups) {
+ arrow::FieldVector fields = {
+ arrow::field("f_int", arrow::int32()),
+ arrow::field("f_bigint", arrow::int64()),
+ arrow::field("f_float", arrow::float32()),
+ arrow::field("f_double", arrow::float64()),
+ arrow::field("f_string", arrow::utf8()),
+ arrow::field("f_binary", arrow::binary()),
+ arrow::field("f_decimal_int32", arrow::decimal128(9, 2)),
+ arrow::field("f_decimal_int64", arrow::decimal128(18, 4)),
+ arrow::field("f_decimal_fixed", arrow::decimal128(30, 2)),
+ arrow::field("f_ts_int96", arrow::timestamp(arrow::TimeUnit::NANO)),
+ arrow::field("f_ts_micro", arrow::timestamp(arrow::TimeUnit::MICRO)),
+ arrow::field("f_date", arrow::date32()),
+ arrow::field("f_all_null", arrow::int32()),
+ arrow::field("f_list", arrow::list(arrow::int32())),
+ arrow::field("f_struct", arrow::struct_({arrow::field("f0",
arrow::int32())})),
Review Comment:
Added in 072b699d. `TestWrittenFileStatsAcrossRowGroups` now includes
`f_map` with type `MAP<STRING, MAP<INT, BIGINT>>`. The data covers a non-empty
inner map, an empty inner map, a null inner map, a null outer map, an empty
outer map and a null inner value, and it spans the 3 row groups. The test
asserts that the stats read back from the footer are a `MAP` column with `min
null, max null, null count null`. `CheckWrittenFileStats` then verifies that
the stats derived from the in-memory writer metadata are identical, including
after `SimpleStatsConverter::ToBinary`.
##########
include/paimon/format/written_file_stats_provider.h:
##########
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include "paimon/result.h"
+#include "paimon/type_fwd.h"
+
+namespace paimon {
+
+/// Implemented by a `FormatWriter` that can produce the column statistics of
the file it has
+/// finished from the metadata it still holds in memory, so the file need not
be reopened through
+/// `FormatStatsExtractor` to read them back.
+///
+/// The interface is internal and implemented alongside `FormatWriter`, so the
exported
+/// `FormatWriter` keeps its ABI.
+class PAIMON_EXPORT WrittenFileStatsProvider {
Review Comment:
Agreed, moved in 072b699d. The header is now
`include/paimon/format/written_file_stats_provider.h`, next to `FormatWriter`
and `FormatStatsExtractor`, and `DataFileWriterBase` and `ParquetFormatWriter`
include it from there. Because it is now part of the public API, I also:
- reworded the class comment so it no longer describes the interface as
internal. It now says a `FormatWriter` can optionally implement it, and that it
sits alongside `FormatWriter` so `FormatWriter` keeps its ABI.
- added `paimon::WrittenFileStatsProvider` to
`docs/source/api/file_format.rst`.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]