Skip to content

Parquet: map the FILE logical type to the arrow.parquet.file extension type - #11877

Merged
etseidl merged 4 commits into
apache:mainfrom
dejankrak-db:parquet-file-arrow-extension
Nov 4, 2026
Merged

etseidl merged 4 commits into
apache:mainfrom
dejankrak-db:parquet-file-arrow-extension

Conversation

@dejankrak-db

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

#10109 added the Parquet FILE logical type, but not its Arrow mapping. A FILE group reads as a plain struct, and ArrowWriter cannot write the annotation, so Arrow-based writers cannot produce conforming FILE columns.

What changes are included in this PR?

Following the Variant precedent:

  • A new parquet::arrow::file_type::FileType extension type, named arrow.parquet.file, with no metadata. Its storage is a struct whose fields are any subset of uri, offset, size, content_type, checksum, inline, each nullable, matching the Parquet-side validation from parquet: introduce FILE logical type #10109 (string fields accept Utf8/LargeUtf8/Utf8View, inline accepts any binary type).
  • Read: try_add_extension_type / has_extension_type tag a FILE group with FileType.
  • Write: logical_type_for_struct returns LogicalType::File for a struct field with FileType; its gating now covers either variant_experimental or file_experimental. Sub-field ids come from the existing PARQUET:field_id metadata.
  • A file_experimental feature (also part of experimental), documented in the README and crate docs, and a CI compile check with --no-default-features --features file_experimental.

Are these changes tested?

Yes, in parquet/src/arrow/file_type.rs: accepted and rejected struct shapes, an Arrow to Parquet to Arrow schema round trip (annotation and field ids), a struct without the extension staying unannotated, and ArrowWriter write and read round trips at the top level and as a list element.

Locally: cargo test -p parquet --all-features --lib passes, cargo clippy -p parquet --all-targets --all-features -- -D warnings is clean, docs build with -D warnings, and cargo check -p parquet passes with default features, variant_experimental only, and file_experimental only.

Are there any user-facing changes?

A new, experimental, opt-in file_experimental feature and FileType extension type. No change without the feature.

The code, tests, and this description were drafted with an AI assistant and reviewed by me before submitting.

This pull request and its description were written by Isaac.

@github-actions github-actions Bot added parquet parquet crate development-process Internal changes; PRs with this label are excluded from changelog labels Oct 23, 2026
@dejankrak-db

Copy link
Copy Markdown
Contributor Author

@etseidl, @Jefffrey, since you reviewed the original PR #10109 that introduced File logical type, could you please help review this PR as well, which is a follow up? Thanks!

@etseidl

etseidl commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Hi @dejankrak-db, thanks for the submission. We've been pretty swamped lately by AI slop, so I've been slow to get deep in my queue. I'll try to give this a look soon.

@etseidl
etseidl self-requested a review November 2, 2026 18:58
@etseidl etseidl added enhancement New feature/addition and removed development-process Internal changes; PRs with this label are excluded from changelog labels Nov 2, 2026

@etseidl etseidl 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.

Thanks @dejankrak-db, this looks good to me, but I'll admit to not being super familiar with this part of the code.

@sdf-jkl or @Rich-T-kid perhaps one of you have a few free cycles to take a look 🙏

Comment on lines +40 to +42
/// When reading, a `FILE`-annotated group is returned as a struct with this
/// extension type. When writing, a struct field with this extension type is
/// written as a `FILE`-annotated group.

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.

Small doc nit my agent brought up, it's possible that a parquet file could have the FILE annotation in the parquet schema, but the embedded arrow schema says it's a plain struct. On read, if the embedded schema is used, the FILE annotation is lost. This isn't anything new or unique to this extension, but it is a caveat that might be worth mentioning here. The workaround is to read with skip_arrow_metadata set to true.

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.

Good point, added a note to the FileType docs with the skip_arrow_metadata workaround.

@Rich-T-kid

Copy link
Copy Markdown
Contributor

taking a look right now

@Rich-T-kid
Rich-T-kid self-requested a review November 3, 2026 20:07
@Rich-T-kid

Copy link
Copy Markdown
Contributor

seeing as there are a few issues/prs that im missing context on I wont be able to finish reviewing this until tonight if you'd like to hold off on merging

@etseidl

etseidl commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Thanks @Rich-T-kid. No rush.

@github-actions github-actions Bot added the development-process Internal changes; PRs with this label are excluded from changelog label Nov 4, 2026

@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.

Looks good to me, left two minor comments. thanks @dejankrak-db & @etseidl for the ping

Comment thread parquet/src/arrow/file_type.rs Outdated
Comment on lines +71 to +73
fn deserialize_metadata(_metadata: Option<&str>) -> Result<Self::Metadata, ArrowError> {
Ok("")
}

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.

FileType serializes its metadata as an empty string, but this accepts every metadata value. Since logical_type_for_struct relies on has_valid_extension_type, a field carrying arbitrary or potentially incompatible future metadata is still written as Parquet FILE.

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.

Good catch. deserialize_metadata now rejects anything but empty metadata, as Uuid does, so such a field is written as a plain group. Added a test.

Comment thread parquet/src/arrow/schema/extension.rs Outdated
Comment on lines +137 to +140
/// files whose annotation does not carry version 1. The value written is
/// [`parquet_variant::VARIANT_SPEC_VERSION`], the same version stamped into
/// every metadata header.
#[cfg(feature = "variant_experimental")]
#[cfg(any(feature = "variant_experimental", feature = "file_experimental"))]

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.

should we also update the doc comment here or is it still accurate?

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.

Oh, good catch. I think the variant bits should be separately gated now. Although reading it now, I wonder if that level of detail even belongs in the docs 🤷

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.

Made the doc general and moved the Variant version detail into a comment on the Variant branch.

@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.

nice work @dejankrak-db

@dejankrak-db

Copy link
Copy Markdown
Contributor Author

Thanks @etseidl and @Rich-T-kid! I have addressed all the comments, can we merge this change?

/// every metadata header.
#[cfg(feature = "variant_experimental")]
/// Return the Parquet logical type to use for the specified Arrow Struct field, if any:
/// `VARIANT` for the Variant extension type and `FILE` for `FileType`.

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.

Not going to delay any longer on this, but if we add a third extension I think I'd not mention any return types here and instead enumerate them in the module docstring.

@etseidl
etseidl added this pull request to the merge queue Nov 4, 2026
Merged via the queue into apache:main with commit 29206c6 Nov 4, 2026
21 checks passed
@Jefffrey Jefffrey removed the development-process Internal changes; PRs with this label are excluded from changelog label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature/addition parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parquet: map the FILE logical type to an Arrow extension type

4 participants