Skip to content

[Parquet] Make default fallback encoding choice smarter #40636

Open

Description

@pitrou

Describe the enhancement requested

Currently, the choice of default encoding for a non-dictionary data page is trivial.
It happens in two places:

  1. in the FallbackToPlainEncoding function for columns for which dictionary encoding is attempted:
    void FallbackToPlainEncoding() {
    if (IsDictionaryEncoding(current_encoder_->encoding())) {
    WriteDictionaryPage();
    // Serialize the buffered Dictionary Indices
    FlushBufferedDataPages();
    fallback_ = true;
    // Only PLAIN encoding is supported for fallback in V1
    current_encoder_ = MakeEncoder(DType::type_num, Encoding::PLAIN, false, descr_,
    properties_->memory_pool());
    current_value_encoder_ = dynamic_cast<ValueEncoderType*>(current_encoder_.get());
    current_dict_encoder_ = nullptr; // not using dict
    encoding_ = Encoding::PLAIN;
    }
    }
  2. in the ColumnWriter::Make factory function for columns for which dictionary encoding is not attempted:
    Encoding::type encoding = properties->encoding(descr->path());
    if (encoding == Encoding::UNKNOWN) {
    encoding = (descr->physical_type() == Type::BOOLEAN &&
    properties->version() != ParquetVersion::PARQUET_1_0 &&
    properties->data_page_version() == ParquetDataPageVersion::V2)
    ? Encoding::RLE
    : Encoding::PLAIN;
    }

I'll note that parquet-mr does not limit dictionary encoding fallback to PLAIN, even for "v1" Parquet files:
https://github.com/apache/parquet-mr/blob/95b004c3df473e3ab0963dc5136934ce5235d5df/parquet-column/src/main/java/org/apache/parquet/column/values/factory/DefaultV1ValuesWriterFactory.java#L124-L139

We should probably consolidate the logic from the two functions above and make it more sophisticated, allowing the best encoding for the selected Parquet version.

Also related: #38441

Component(s)

C++, Parquet

Activity

  1. ClifHouck commented on Mar 27, 2024

    @ClifHouck
    Contributor

    Going to take a look at this if no one objects.

  2. github-actions commented on Nov 18, 2025

    @github-actions

    This issue has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label or comment below, or this issue will be closed in 14 days. If this improvement is still desired but has no current owner, please add the 'Status: needs champion' label.

  3. added
    Status: stale-warningIssues and PRs flagged as stale which are due to be closed if no indication otherwise
    on Nov 18, 2025
  4. added
    Status: needs championHigh impact issues which aren't being worked on but require a volunteer to move the task forward.
    and removed
    Status: stale-warningIssues and PRs flagged as stale which are due to be closed if no indication otherwise
    on Nov 18, 2025
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