Skip to content

Parquet: accept zstd compression level 0 and negative levels in ZstdLevel #11545

Open

Description

@andygrove

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

parquet::basic::ZstdLevel::try_new accepts only levels 1 to 22 (MINIMUM_LEVEL = 1, MAXIMUM_LEVEL = 22 in parquet/src/compression.rs). zstd itself also accepts:

  • level 0, which means its default level (ZSTD_CLEVEL_DEFAULT, 3)
  • negative "fast" levels, down to ZSTD_minCLevel(), which trade compression ratio for speed

parquet-java (through zstd-jni) accepts both, so a writer that wants to honor a table's configured zstd level cannot do so with parquet-rs. Apache Iceberg tables, for example, can set write.parquet.compression-level to 0 or a negative value, and iceberg-java writes them; DataFusion Comet's native Iceberg writer has to fall back to the JVM writer for those tables.

Describe the solution you'd like

Let ZstdLevel accept the full range the linked zstd library supports (zstd::compression_level_range()), including 0 and negative levels, and pass them through to the encoder unchanged.

Describe alternatives you've considered

Callers can map 0 to 3 themselves, but there is no equivalent for the negative levels.

Additional context

compression_level_range() is not const, which is presumably why the bounds are hard-coded today.

Activity

  1. bharadwaj-pendyala commented on Oct 23, 2026

    @bharadwaj-pendyala
    Contributor

    I think this already landed in #10601, which shipped in 60.0.0. ZstdLevel::MINIMUM_LEVEL is now -131072, so try_new accepts 0 and the negative levels, and ZSTDCodec::new passes the level straight to zstd::bulk::Compressor. The 1 to 22 bounds in the description match 59.x, so Comet may only need the 60 upgrade.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature/additionparquetChanges to the parquet crate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions