Skip to content

[Parquet] Encoding configuration should be easier and more automated #38441

Open

Description

@pitrou

Describe the enhancement requested

Right now, configuring good encoding values is difficult for users. There is nothing to help them make those decisions, and the defaults are a bit simplistic (try RLE_DICTIONARY then fall back on PLAIN, IIUC). If they want to override encodings, they have to do so on a column-by-column basis (which probably becomes very cumbersome if there hundreds of columns).

Ideally, there should be a way for users to get an automatic selection of encodings, based on their data or at least their data types (and also the selected Parquet version), that provides a good compromise between disk footprint and decoding speed.

(in Python, think pq.write_table(..., column_encoding="auto"))

Perhaps it would be also nice for users to pass per-datatype preferences, rather than per-column.

Component(s)

C++, Parquet

Activity

  1. pitrou commented on Oct 24, 2023

    @pitrou
    MemberAuthor
  2. pitrou commented on Oct 24, 2023

    @pitrou
    MemberAuthor

    Also @mrocklin, perhaps you have specific API suggestions here.

  3. jorisvandenbossche commented on Oct 24, 2023

    @jorisvandenbossche
    Member

    At the very least, we should also improve the documention around the different encoding options. Currently we just have this table listing them: https://arrow.apache.org/docs/dev/cpp/parquet.html#encodings (and this brief section in the Python user guide: https://arrow.apache.org/docs/dev/python/parquet.html#compression-encoding-and-file-compatibility)
    For example mention for which data types they are relevant (eg BYTE_STREAM_SPLIT is only for floats, DELTA_BINARY_PACKED for integers), or if they are useful for specific characteristcs (eg many repeated values, sorted data, ..), etc.

  4. mapleFU commented on Oct 25, 2023

    @mapleFU
    Member

    https://www.cs.cit.tum.de/fileadmin/w00cfj/dis/papers/btrblocks.pdf

    I remember here is a policy here. Though I think this paper has something weird, we can be able to using it.

    0AFBE093-828B-46B9-81DD-8C3FD02A64FF

    However, hacking the encoder would be tricky...Currently the encoder depends on dict_encoder_ or etc, it would be a bit tricky to having a Adaptive encoder within it. Besides, different user would has different requirements. We need to balance the file-size ( related-to IO ) and the decompression/decoding speed ( CPU -bound)

  5. wgtmac commented on Oct 25, 2023

    @wgtmac
    Member

    https://www.cs.cit.tum.de/fileadmin/w00cfj/dis/papers/btrblocks.pdf

    That paper looks a little bit academic to me as it would significantly affect the write time. In many common cases, a simple sampling process (e.g. on first N input values if not skewed) would help determine a proper encoding.

  6. pitrou commented on Oct 25, 2023

    @pitrou
    MemberAuthor

    Yes, and perhaps the encoding decisions can be remembered for the entire row batch (or the entire file?).

  7. mapleFU commented on Oct 25, 2023

    @mapleFU
    Member

    Another problem is that, for DataPageV1, we need to both considering compression and encoding(DataPage V2 can choose not to compression if compression ratio is low). This make deciding the adaptive encoding more complex.

  8. pitrou commented on Oct 25, 2023

    @pitrou
    MemberAuthor

    We can decide not to support DataPageV2 for this feature if it makes things easier.

  9. mapleFU commented on Oct 25, 2023

    @mapleFU
    Member

    Yeah, I mean, usally user would pickup a compression. For datapagev1, it doesn't support a is_compression flag. So, all the page should be compressed ( whenever the compression ratio is)

    The funny thing is that, if we meet some data, and have PLAIN DELTA as candidate. DELTA might be better if not compression, but considering compression, PLAIN is better.

    Sometimes, the compression size even grows larger for some input. DataPageV2 can reject to compress for these types, but DataPageV1 cannot.

  10. wgtmac commented on Oct 26, 2023

    @wgtmac
    Member

    I think it is better to decouple encoding and compression, though some compression codecs may favor different encoding schemes when data pattern varies. So it would be easier if we just focus on "best" encoding that we can decide from sample data regardless of follow-up compression. Then probably we don't have to bother with DataPage version at the moment.

  11. pitrou commented on Oct 26, 2023

    @pitrou
    MemberAuthor

    Well, for example, the only point of BYTE_STREAM_SPLIT is that the encoded output compresses better. But if you don't compress, it's exactly the same size as the input.

    So I'm afraid the strategy should take compression into account somehow, if some kind of sampling is used.

    That said, the strategy can also not use sampling at all, and instead rely on simple heuristics (which ones?).

    All this probably means is that:

    • we should offer a flexible API for users to implement their own strategy
    • we should also offer a decent default strategy for the majority of users

    I can draft an API when I find the time, which would be in a couple weeks probably (feel free to ping me :-)).

  12. mapleFU commented on Oct 26, 2023

    @mapleFU
    Member

    How could you sampling and doing this?🤔 I've implement a similiar one but I must say it isn't suitable for all cases and the interface would be tricky(for example, handling dict is tricky). Also, when NULL FIRST is setting, we cannot sampling any data.

  13. mapleFU commented on Oct 26, 2023

    @mapleFU
    Member

    Also, would it related to: #33885 ?

  14. pitrou commented on Oct 26, 2023

    @pitrou
    MemberAuthor

    Slighty related, but also independent IMHO.

  15. wgtmac commented on Oct 26, 2023

    @wgtmac
    Member

    Parquet is usually used as a low-level library in the database or data warehouse, which has a better knowledge of the actual data pattern. They can decide the best combination of encoding and compression for any column based on the data already stored. Should we provide a simple tool or something to evaluate each page of every column from an input parquet file and decides the best encoding & compression for them?

  16. pitrou commented on Oct 26, 2023

    @pitrou
    MemberAuthor

    Should we provide a simple tool or something to evaluate each page of every column from an input parquet file and decides the best encoding & compression for them?

    Such a tool can easily be developed as a separate project. Here we're talking about allowing users to get better defaults out of Parquet C++.

  17. added
    Status: stale-warningIssues and PRs flagged as stale which are due to be closed if no indication otherwise
    on Feb 18, 2026
  18. thisisnic commented on Feb 18, 2026

    @thisisnic
    Member

    This issue has been marked as stale because it has had no activity in the past 2 years. Please remove the stale label or comment below, or this issue will be closed in 14 days.

  19. daniel-x commented on Apr 15, 2026

    @daniel-x

    I'm interested to work on this issue, as I see high potential in it for reduced file sizes, which is a strong reason for choosing parquet as a file format for long term storage - and we would improve io speed at the same time. I personally work with data where slightly more detailed encoding defaults would reduce my zstd compressed file sizes by about 20%. Currently, specifying encoding per-column through the Python API requires a fair bit of manual configuration, which can be a barrier for new users.

    Here is how I think about scoping a first step:

    • I suggest targeting simple, low-risk changes that harvest large gains.
    • We can set defaults for encoding per column based on
      • datatype of the column
      • subsequent compression
      • version of the parquet file (for compatibility) # can be omitted and simplified by choosing always-compatible defaults
      • (no sampling of column content in this first step, because this is where it gets tricky)

    I believe this will address many of the common cases.

    Technically, encoding can be decoupled from subsequent compression, but it can cause larger file sizes and worse io speed, as demonstrated by the benchmarks in issue #49715. Hence, I think encoding should take compression into account in order to get best results, even though it increases code complexity.

    I'd be happy to put together an initial PR if this direction sounds reasonable. Happy to hear if there are considerations I'm missing.

  20. daniel-x commented on May 10, 2026

    @daniel-x

    Please let me know if there is interest by other developers in me implementing something and/or if I should use another medium for the discussion, like the mailing list or something else.

  21. kou commented on May 10, 2026

    @kou
    Member
  22. removed
    Status: stale-warningIssues and PRs flagged as stale which are due to be closed if no indication otherwise
    on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions