Skip to content

[C++][Parquet] Support min_value and max_value Statistics #14870

Closed as not planned

Description

@pitrou

Describe the enhancement requested

The Statistics structure in Parquet files provides two ways of specifying lower and upper bounds for a data page:

  • min and max are legacy fields for compatibility with older writers, with ill-defined comparison semantics in most cases except for signed integers
  • min_value and max_value are "new" fields (introduced in 2017! - see apache/parquet-format@041708d and apache/parquet-format@bef5438) with well-defined comparison semantics depending on the logical type

Currently Parquet C++ supports only the legacy fields min and max. We should add support for reading and writing the newer ones, with the appropriate semantics on the write path.

Component(s)

Parquet

Activity

  1. pitrou commented on Dec 7, 2022

    @pitrou
    MemberAuthor
  2. wgtmac commented on Dec 7, 2022

    @wgtmac
    Member

    AFAIK, the statistics in the data page header has been deprecated after column index (part of the page index) has been introduced.

    CMIW, parquet cpp is in good state with the parquet spec:

  3. wgtmac commented on Dec 7, 2022

    @wgtmac
    Member

    AFAIK, the statistics in the data page header has been deprecated after column index (part of the page index) has been introduced.

    CMIW, parquet cpp is in good state with the parquet spec:

    The confusing thing is that both Statistics and EncodedStatistics use min and max for both old and new meanings.

  4. pitrou commented on Dec 7, 2022

    @pitrou
    MemberAuthor

    CMIW, parquet cpp is in good state with the parquet spec:

    Uh, I had missed that. I agree that things seem fine.

  5. wgtmac commented on Feb 9, 2023

    @wgtmac
    Member

    @pitrou Could you please reopen this issue? I found that there is a missing part: The C++ parquet reader does not parse column statistics correctly here: https://github.com/apache/arrow/blob/master/cpp/src/parquet/column_reader.cc#L214

    // Extracts encoded statistics from V1 and V2 data page headers
    template <typename H>
    EncodedStatistics ExtractStatsFromHeader(const H& header) {
      EncodedStatistics page_statistics;
      if (!header.__isset.statistics) {
        return page_statistics;
      }
      const format::Statistics& stats = header.statistics;
      if (stats.__isset.max) {
        page_statistics.set_max(stats.max);
      }
      if (stats.__isset.min) {
        page_statistics.set_min(stats.min);
      }
      if (stats.__isset.null_count) {
        page_statistics.set_null_count(stats.null_count);
      }
      if (stats.__isset.distinct_count) {
        page_statistics.set_distinct_count(stats.distinct_count);
      }
      return page_statistics;
    }
    

    It should check __isset.min_value and __isset.max_value first which is similar to parquet-mr: https://github.com/apache/parquet-mr/blob/5290bd5e0ee5dc30db0576e2bfc6eea335c465cf/parquet-hadoop/src/main/java/org/apache/parquet/format/converter/ParquetMetadataConverter.java#L797

  6. added a commit that references this issue on Feb 10, 2023
  7. pitrou commented on Feb 10, 2023

    @pitrou
    MemberAuthor

    @wgtmac You should probably open a new issue instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions