Skip to content

feat(parquet): support round-trip of Dictionary(_, Utf8View/BinaryView) columns - #10831

Merged
Jefffrey merged 4 commits into
apache:mainfrom
adamreeve:utf8view-dict-write
Aug 27, 2026
Merged

feat(parquet): support round-trip of Dictionary(_, Utf8View/BinaryView) columns#10831
Jefffrey merged 4 commits into
apache:mainfrom
adamreeve:utf8view-dict-write

Conversation

@adamreeve

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Allows reading and writing this data type with Parquet. This is particularly useful for working with Polars categorical types, which use a Dictionary(UInt32, Utf8View) representation.

What changes are included in this PR?

  • Add missing match arms to support downcasting these arrays to a binary array when writing Parquet.
  • Add support for BinaryView and Utf8View value types in ByteArrayDictionaryReader to allow reading this data back as the same type.

Are these changes tested?

Yes, I've added a new unit test to cover this.

Are there any user-facing changes?

Yes, this is new user-facing functionality.

@github-actions github-actions Bot added the parquet Changes to the parquet crate label Aug 25, 2026

/// Convert a dictionary-typed array with string or binary typed values
/// to one with string or binary view typed values.
fn convert_values_to_view(array: ArrayRef, to_type: &ArrowType) -> Result<ArrayRef> {

@adamreeve adamreeve Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DictionaryBuffer only works with an OffsetBuffer, not a ViewBuffer, so this extra conversion step is required:

Values { values: OffsetBuffer<V> },

Maybe DictionaryBuffer could be refactored to avoid this or a new flavour of DictionaryBuffer could be created that works with view types, but that seems like it would be a much more complex change. This probably isn't too performance sensitive as it only needs to convert the dictionary values.

I'm happy to look into making this work without the extra copy if we think that's needed though.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea after this is shipped I think this is worth making a follow up issue for to track.

@adamreeve
adamreeve marked this pull request as ready for review August 25, 2026 09:28

@Rich-T-kid Rich-T-kid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR looks very good. I think we can squeeze out a bit more performance when creating the output array in convert_values_to_view


/// Convert a dictionary-typed array with string or binary typed values
/// to one with string or binary view typed values.
fn convert_values_to_view(array: ArrayRef, to_type: &ArrowType) -> Result<ArrayRef> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea after this is shipped I think this is worth making a follow up issue for to track.

Comment thread parquet/src/arrow/array_reader/byte_array_dictionary.rs Outdated
@adamreeve

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look @Rich-T-kid, I've pushed a change to remove the ArrayDataBuilder validation.

@Rich-T-kid

Copy link
Copy Markdown
Contributor

will take a second look tommorow 👍

@Jefffrey Jefffrey added the enhancement Any new improvement worthy of a entry in the changelog label Aug 26, 2026
Comment thread parquet/src/arrow/array_reader/byte_array_dictionary.rs Outdated
Comment thread parquet/src/arrow/array_reader/byte_array_dictionary.rs Outdated

@Rich-T-kid Rich-T-kid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I wasn't aware that this previously wasn't supported, should be very useful for apache/datafusion#24111. thank you @adamreeve

@Jefffrey
Jefffrey merged commit b266024 into apache:main Aug 27, 2026
1 check passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @adamreeve & @Rich-T-kid

@adamreeve
adamreeve deleted the utf8view-dict-write branch August 27, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Any new improvement worthy of a entry in the changelog parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic writing a Dictionary(_, Utf8View) typed column to Parquet

3 participants