Skip to content

Support the Parquet FILE logical type - #125132

Merged
alexey-milovidov merged 9 commits into
masterfrom
parquet-file-logical-type
Oct 13, 2026
Merged

alexey-milovidov merged 9 commits into
masterfrom
parquet-file-logical-type

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Support the Parquet FILE logical type (https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#file) in the native Parquet reader and writer. It annotates a group that references a range of bytes stored inline or in an external file (fields uri, offset, size, content_type, checksum, inline).

The first commits update contrib/arrow to have the FILE logical type in the generated Thrift code (sync of parquet.thrift with apache/parquet-format master).

Reading: a FILE group is read as a named Tuple of the fields present in the file: Nullable(String) for uri, content_type, checksum, inline and Nullable(Int64) for offset, size. Type hints, subsets and subcolumns work as for other groups. The schema of the group is validated (field names, types, OPTIONAL repetition) and a non-conforming schema throws INCORRECT_DATA. Row values are returned as stored, without checking that they form a valid reference.

Writing: with the new setting output_format_parquet_write_file_logical_type (disabled by default, because readers that do not know the type, e.g. Arrow C++ / pyarrow, cannot open such files), a named Tuple whose element names are all FILE fields is written as a FILE-annotated group with OPTIONAL fields.

Interoperability is tested with a file written by arrow-rs (which has FILE support since apache/arrow-rs#10109); arrow-rs also reads files written by ClickHouse.

Related: ClickHouse/arrow#87

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Support the Parquet FILE logical type (a reference to bytes stored inline or in an external file): it is read as a named Tuple, and can be written from a Tuple with the corresponding element names with the new setting output_format_parquet_write_file_logical_type.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/125132]

Version info

  • Merged into: 26.10.1.2334-master (included in 26.10 and later)

alexey-milovidov and others added 5 commits October 11, 2026 00:48
…ormat master

This brings the `ALP` encoding and the `FILE` logical type into the generated
Thrift code used by the native Parquet reader and writer.

Related: ClickHouse/arrow#87

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tree is identical; this points the submodule at the commit on the
`ClickHouse/apache-arrow-25.0.0` branch.

Related: ClickHouse/arrow#87

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`FILE` (added to parquet-format in 2026) annotates a group that references a range of bytes stored
inline or in an external file, with any subset of the `OPTIONAL` fields `uri`, `offset`, `size`,
`content_type`, `checksum`, `inline`.

Reading: the schema of a `FILE` group is validated (only these fields, `OPTIONAL`, with the types
from the specification; otherwise `INCORRECT_DATA`), then the group is read as an ordinary named
`Tuple` of `Nullable` elements, so subsets of fields and subcolumns work as for any tuple. Values
are not validated. A repeated `FILE` group under `LIST` is the list element even with one field.

Writing: with the new setting `output_format_parquet_write_file_logical_type`, a named `Tuple` whose
element names are a non-empty subset of the `FILE` fields is written as a `FILE`-annotated group,
with integer `offset`/`size` converted to `Int64` and string fields to `String`, all `OPTIONAL`.

The tests include a reference file written by arrow-rs (`parquet` crate, which implements `FILE`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
It contains raw binary `inline` values and is tested by `05361_parquet_file_logical_type_arrow_rs`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6e80547]

Summary: ✅


AI Review

Summary

This PR adds native Parquet reader and writer support for the FILE logical type, including schema validation for malformed FILE groups, write-side emission behind output_format_parquet_write_file_logical_type, documentation updates, and focused stateless coverage for round trips, schema validation, and arrow-rs interoperability. I reviewed the current diff together with the prior discussion thread and did not find any remaining correctness, safety, or contract issues that warrant new inline comments.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-feature Pull request with new product feature submodule changed At least one submodule changed in this PR. comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). labels Oct 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 6e80547f5aaece62c5b3c0edff3d42247af3b601 was not compared: the CI logs cluster did not answer (exception 241, code 500: { "meta": [ { "name": "file", "type": "LowCardinality(String)" …).

See the job log for details.

alexey-milovidov and others added 2 commits October 12, 2026 17:17
A malformed schema with `logicalType.FILE` on a primitive element was read
as an ordinary scalar instead of being rejected with `INCORRECT_DATA`.
Add a test case for it to `05360_parquet_file_logical_type_schema_validation`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125132&sha=d365d68dcd1b0bc928d40ef24c752fa928bee61f&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 (05210_lightweight_update_materialized_cte_in_ignore times out, also on master and many other PRs) and provide a fix in a separate PR. If the fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

The fix is already in progress: #123121 (mine, open).

The linked run is not a timeout. 05210 failed after 5.2 s with Code: 60 ... Unknown table expression identifier '_materialized_cte_c_10190799586122421013' (query 26, line 79), and 164/164 reruns passed. CIDB has no timeout of this test in the last 7 days: its ~200 failures there (master and ~150 PRs, all in the ParallelReplicas lanes) have this same UNKNOWN_TABLE signature.

This is the #112642 race: with a local plan, the query sent to the replicas can start before the initiator has materialized the CTE. On #123121 (head eb9385ea), 05210 passes in this lane.

#123121 is waiting for review from @ novikd and @ devcrafter.

@clickhouse-gh clickhouse-gh Bot added comp-parquet-reader-v3 Issues related to the native Parquet reader. and removed comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). labels Oct 12, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Thanks, @groeneai. Understood: the 05210_lightweight_update_materialized_cte_in_ignore failure is the UNKNOWN_TABLE race from #112642, unrelated to this PR, and #123121 fixes it. CI on the current head (6e80547f) is green, so this PR needs no changes.

@alexey-milovidov alexey-milovidov left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The code LGTM. This is an obscure feature, hardly supported by anyone. But it is in the spec, and we can let it in our codebase. For the readers, one obvious thing: we don't read arbitrary external files 🤣 Otherwise, it would be a million-dollar trap like XXE.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 13, 2026
@alexey-milovidov alexey-milovidov self-assigned this Oct 13, 2026
Merged via the queue into master with commit b28f384 Oct 13, 2026
178 checks passed
@alexey-milovidov
alexey-milovidov deleted the parquet-file-logical-type branch October 13, 2026 23:04
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-parquet-reader-v3 Issues related to the native Parquet reader. pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants