Yes the compression behavior is expected. The encryption behavior is not
imho.

On Fri, Nov 13, 2026 at 6:24 PM Julien Le Dem via dev <
[email protected]> wrote:

> My personal recollection is the compression applying only to values in
> DataPageV2 is intended. The idea is the levels encoded in
> bitPacked_RLE_hybrid are not compressable anymore by the general
> compression. compression also becomes optional by page for values in case
> it only creates overhead if values encoding is already very efficient.
>
> However encryption should be applied to the whole page IMO. This might be
> an artifact of implementing encryption at the same layer as compression for
> DataPageV1 which works in that case but doesn't for DPV2. I am also in
> favor of making a forward incompatible change for parquet-java as the
> existing behavior is incorrect IMO.
>
> On Fri, Nov 13, 2026 at 1:19 PM Russell Spitzer <[email protected]
> >
> wrote:
>
> > Hopefully this got your attention. I promise this is not an
> exaggeration. I
> > do want to break encryption in parquet-java but I promise it's for a good
> > reason.
> >
> > *TLDR; Parquet-java is writing unencrypted levels with V2Pages, breaking
> > compatibility with all other Apache implementations. We should fix this
> > even if it means breaking compatibility with older parquet-java readers.*
> >
> > So first a quick story
> >
> > When modular encryption was introduced, it treated DataPageV1 as a nice
> > blob of data. Levels and Values all lived together in a happy pile of
> data.
> > Encryption took this happy pile of data and encrypted it all together,
> just
> > like compression. Whatever was compressed was encrypted.
> >
> > DataPageV2 is different: the levels are not compressed with the page
> > values. A V2Page contains uncompressed levels, followed by compressed
> > values. I do not think this was intentional, but the writer
> implementation
> > in parquet-java re-used existing patterns, causing us to write
> unencrypted
> > levels alongside encrypted values. A V1 page is written with everything
> > encrypted, a V2 page is written with the levels in plaintext.
> >
> > Now this would only be a minor security issue (Talk to your security
> team,
> > it may be a bigger deal for you) except many implementations did this
> > correctly.
> >
> > PME DataPageV2 Interop: Divergent encryption of rep/def levels between
> > parquet-java and Arrow <
> https://github.com/apache/parquet-java/issues/3934
> > >
> >
> > Now, Parquet-Java (and Trino to my knowledge) writes and reads V2Pages as
> > if they don't have encrypted levels. However, Parquet-C++, Parquet-rs,
> > Parquet-Go, Polars, and DuckDB all write or read V2 pages as if the
> entire
> > page is encrypted.
> >
> > So there is essentially a fork now. Implementations either do not encrypt
> > the whole page or they do encrypt the whole page. This only affects
> > encrypted columns written with V2 pages, which parquet-java doesn't write
> > by default.
> >
> > My suggestion is that we unify the two by breaking Parquet-Java's
> backward
> > compatibility. It's arguable that we are doing the incorrect thing in
> > parquet-java and all the other implementations are correct. To do so I
> > propose changing the behavior in version 1.19.0 to start writing correct
> > fully encrypted pages while retaining the ability to read the partially
> > encrypted V2 pages written by previous parquet-java versions. This would
> > cause cross version compatibility issues when previous Parquet-Java
> > versions read files written by 1.19.0, but would get us compatibility
> with
> > the rest of the ecosystem.
> >
> > My PR to Break/Fix DataPageV2 Encryption in Parquet java
> > <https://github.com/apache/parquet-java/pull/3935>
> >
> > Gidon also proposed a slight correction to the one ambiguous place in the
> > modular encryption spec that supports the current parquet-java
> > implementation (although all other references imply the whole page is
> > encrypted).
> >
> > GH-636: Encryption spec compatibility with version 2 of data pages
> > <https://github.com/apache/parquet-format/pull/637>
> >
>

Reply via email to