Skip to content

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

Open
adamreeve wants to merge 1 commit into
apache:mainfrom
adamreeve:utf8view-dict-write
Open

feat(parquet): support round-trip of Dictionary(_, Utf8View/BinaryView) columns#10831
adamreeve wants to merge 1 commit 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 on lines +151 to +157
let new_data = data
.into_builder()
.data_type(to_type.clone())
.child_data(vec![new_values.to_data()])
.build()?;

Ok(make_array(new_data))

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.

I think we can avoid the extra validation that ArrayDataBuilder performs here.

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

Labels

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

2 participants