Skip to content

Read Paimon ROW columns as named Tuple - #128330

Merged
fm4v merged 2 commits into
ClickHouse:masterfrom
groeneai:paimon-row-type-as-tuple
Nov 2, 2026
Merged

fm4v merged 2 commits into
ClickHouse:masterfrom
groeneai:paimon-row-type-as-tuple

Conversation

@groeneai

@groeneai groeneai commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #128307
Related: #128295

Changelog category (leave one):

  • Improvement

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

Paimon tables with a ROW column can now be read: a ROW is read as a named Tuple, like an Iceberg or Delta Lake struct, and a NULL ROW as a tuple of its fields' default values (NULL for nullable fields). Before, every query on such a table failed with Unsupported Paimon type: ROW, even one that did not read the ROW column. Closes #128307.

Description

A Paimon table with a ROW (struct) column, as written by Spark (STRUCT<...>), Flink or pypaimon, could not be read at all: DESCRIBE, SELECT * and SELECT id failed with Unsupported Paimon type: ROW (BAD_ARGUMENTS). Found by the foreign-writer fuzzer in #128295.

Root cause. Paimon::DataType::parse maps every field of the schema file while the table schema is loaded, and its composite branch knew only ARRAY and MAP.

The change. A ROW is parsed recursively into Tuple(<name> <type>, ...), so each field keeps its own nullability and nested ROW/ARRAY/MAP work. A nullable composite is no longer passed through makeNullableSafe: that was a no-op for Array/Map, and for a Tuple it would produce Nullable(Tuple(...)), which the Parquet reader rejects (TYPE_MISMATCH) when the struct's fields are nullable, the usual Paimon shape. Iceberg and Delta Lake map struct the same way. The ROW row is added to the documented type mapping.

Sub-fields are matched by name, not by Paimon field id, so the rename case of #127545 also applies to them; that is out of scope here.

Validation. New test_types.py::test_row_type (s3 and azure, written by Spark) covers ROW NOT NULL, NOT NULL fields, nested ROW, ARRAY/MAP inside a ROW, ARRAY<ROW>, MAP<K, ROW>, a NULL row (nullable and NOT NULL fields) and subcolumn reads; it fails on master. test_errors.py::test_unsupported_row_type asserted the removed error and is deleted; 04401_paimon_unsupported_type_error now uses MULTISET (still unsupported) as its example. The issue's pypaimon repro returns 1 ('a',1). The Paimon stateless tests and test_types.py/test_errors.py pass.


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

Version info

  • Merged into: 26.11.1.1063-master (included in 26.11 and later)

groeneai and others added 2 commits October 31, 2026 00:06
A Paimon table with a `ROW` (struct) column, as written by Spark, Flink
or pypaimon, could not be read at all: `DESCRIBE`, `SELECT *` and even
`SELECT id` failed with `Unsupported Paimon type: ROW`, because
`Paimon::DataType::parse` maps every field of the schema while the table
schema is loaded and its composite branch knew only `ARRAY` and `MAP`.

A `ROW` is now parsed recursively into `Tuple(<name> <type>, ...)`.

A nullable composite is no longer passed through `makeNullableSafe`. It
was a no-op for `Array` and `Map`, and for a `Tuple` it produces
`Nullable(Tuple(...))`, which the Parquet reader rejects for a struct
with nullable fields (the usual Paimon shape). Measured with the wrap
kept for `ROW`: `DESCRIBE` reports
`Nullable(Tuple(f0 Nullable(String), f1 Nullable(Int32)))` and
`SELECT *` fails with `Requested type of column s doesn't match parquet
schema: parquet type is Tuple, requested type is Nullable(Tuple(...))`
(TYPE_MISMATCH), and the new integration test is red at its `DESC`
assertion. Iceberg and Delta Lake map `struct` to an unwrapped `Tuple`
as well, so a `NULL` row reads as a tuple of the fields' defaults.

`test_errors.py::test_unsupported_row_type` asserted the removed error
and is replaced by `test_types.py::test_row_type`. `04401` used `ROW` as
its example of an unsupported nested type and now uses `MULTISET`.

Closes ClickHouse#128307

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add a nullable `s_req STRUCT<x: INT NOT NULL>` column. Its NULL row reads
as `(0)`: a NULL ROW becomes a tuple of its fields' default values, and the
default of a NOT NULL INT field is 0.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 rounds, 1 finding) plus my own review (3 nits).

# Sev Finding Verdict Evidence / action
1 ⚠️ test_row_type had no NULL ROW with a NOT NULL sub-field (test_types.py) AGREE, fixed s_req STRUCT<x: INT NOT NULL> added; its NULL row reads (0); re-review of the fix: 0 findings
2 💡 changelog entry said a NULL ROW is a tuple of NULLs, but a NOT NULL sub-field reads its default AGREE, fixed entry wording corrected
3 💡 sub-fields are matched by name, so the rename case of #127545 applies to them DISAGREE column resolution, not type mapping; separate PR (#127816 covers top-level), stated in the description
4 💡 a corrupt ROW without fields fails with Null pointer (POCO_EXCEPTION) DISAGREE an exception, not a crash; same as the top-level fields loop

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The issue's pypaimon 2.1.0 script, then SELECT id FROM paimonLocal(...): Code: 36 Unsupported Paimon type: ROW on master every time; test_row_type fails on master 2/2 (s3, azure).
b Root cause explained? Paimon::DataType::parse runs for every schema field at schema load, and its composite branch handled only ARRAY/MAP, so a ROW field made every query on the table throw.
c Fix matches root cause? Yes. ROW is parsed into the named Tuple the data-file readers produce; the composite Nullable wrap (a no-op for Array/Map) is removed because Nullable(Tuple) is rejected by the Parquet reader for nullable fields. No guard or fallback.
d Test intent preserved / new tests added? New test_types.py::test_row_type (s3 + azure). test_unsupported_row_type asserted the removed error and is deleted; 04401 keeps testing the descriptive error with MULTISET.
e Both directions demonstrated? master: test_row_type 2 failed; fix: 10 passed (5 runs x 2 storages). Keeping the Nullable wrap for ROW turns it red at DESC (Nullable(Tuple(...))), and SELECT * then fails TYPE_MISMATCH.
f Fix is general across code paths? DataType::parse is the only Paimon type parser; its consumers need no change (partition keys are primitive-only, manifest stats stay raw). Iceberg and Delta Lake already map struct to Tuple.
g Fix generalizes across inputs (params/datatypes/wrappers)? Tested: nullable and NOT NULL ROW, NOT NULL fields, nested ROW, ARRAY/MAP in ROW, ARRAY<ROW>, MAP<K, ROW>, NULL row, subcolumns; probed Parquet and ORC files, empty fields, empty/null/duplicate sub-field names (clean errors).
h Backward compatible? (maintainer-approved exception only) Yes. No setting or format change; tables that failed to load now load; ARRAY/MAP types are unchanged (Paimon stateless tests and test_all_types pass).
i Invariants and contracts preserved? Each element keeps its own parsed type and the outer type is never Nullable, which is what the Parquet/ORC readers accept. A malformed schema still raises an exception, never an abort.

Session id: cron:clickhouse-impl-slot-7:20261030-234000

@clickhouse-gh

clickhouse-gh Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [86206a3]

Summary: ❌

job_name test_name status info comment
Performance Comparison (arm_release, master_head, 5/6) FAIL Performance dashboard
complex_array_creation #0 FAIL dashboard IGNORED
complex_array_creation #1 FAIL dashboard IGNORED

AI Review

Summary

This PR makes Paimon tables containing ROW columns readable by mapping them recursively to named Tuple types, preserving field nullability and normalizing null composite values consistently with Iceberg and Delta Lake. The regression coverage includes nested rows, collections, null rows with non-nullable fields, and subcolumn reads. No actionable findings remain.

Missing context / blind spots
  • ⚠️ Runtime validation relies on the author's reported before/after runs; no local build or integration environment was available. The targeted integration reports currently expose no per-test results. Completed CI results for test_row_type would provide independent confirmation.
Final Verdict

Status: ✅ Approve.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @JiaQiTang98 @SmitaRKulkarni, could you review this and add the can be tested label so CI runs? The Paimon type parser now maps a ROW field recursively to a named Tuple (not wrapped in Nullable, as Iceberg and Delta Lake do for struct), so a table with a ROW column no longer fails to load with Unsupported Paimon type: ROW.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Oct 31, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Oct 31, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 31, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 86206a3ce with master 9f79cc172 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

6 object files changed (-165.79 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/ObjectStorage/DataLakes/Paimon/PaimonTableSchema.cpp.o 421.95 KiB 244.56 KiB -177.39 KiB (-42.04%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

30 translation units recompiled, 311 s compile time in total, 30 of them have a recent master baseline.

Job report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 86206a3

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Performance Comparison (arm_release, master_head, 5/6) / complex_array_creation #1 not from this PR: SELECT count() FROM zeros(10000000) WHERE NOT ignore([[], [zero]]) never reaches the Paimon code this PR changes. Confirmed +41.1% (+42.1% after the server restart). The same query was reported slower on arm on 5 other PRs and one master run in the last 30 days, #128092 in the same shard today a fix task is created (investigating at full effort, fixing-PR link to follow here)
Mergeable Check, PR praktika rollups of the row above a fix task is created (the same task as the row above)
Sync - CH Inc sync (private, not actionable by me)

The first runs of this head stopped at Config Workflow / Pre Hooks because the can be tested label was not set yet; the run after the label was added is the one above. CIDB has no other FAIL or ERROR row in that run.

Session id: cron:our-pr-ci-monitor:20261031-140009

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the complex_array_creation #1 Performance Comparison (arm_release) row: #128389. It removes the per-element virtual insertFrom chain that was 83-89% of this query in the CPU profiles.

@fm4v
fm4v enabled auto-merge November 1, 2026 09:19
@fm4v
fm4v added this pull request to the merge queue Nov 2, 2026
Merged via the queue into ClickHouse:master with commit 92ff928 Nov 2, 2026
703 of 708 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paimon tables with a ROW (struct) column are unreadable: "Unsupported Paimon type: ROW"

4 participants