Skip to content

Read Paimon DATE as Date32 instead of Date - #128329

Merged
fm4v merged 4 commits into
ClickHouse:masterfrom
groeneai:paimon-date-as-date32
Nov 2, 2026
Merged

fm4v merged 4 commits into
ClickHouse:masterfrom
groeneai:paimon-date-as-date32

Conversation

@groeneai

@groeneai groeneai commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #128306
Related: #128295

Changelog category (leave one):

  • Improvement

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

Paimon DATE columns are now read as Date32 instead of Date, like Iceberg and Delta Lake, so dates before 1970-01-01 or after 2149-06-06 are read instead of failing with VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE. DESCRIBE and toTypeName now report Date32. Closes #128306.

Description

Reading a Paimon table fails with VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE (Input value -1 is out of allowed Date range) as soon as a DATE column holds a day before 1970-01-01 or after 2149-06-06, while file() on the same data file returns the rows. Found by the data lake fuzzer of #128295 (spark_paimon).

Paimon::DataType::parse mapped DATE to Date, and that is the type the Parquet, ORC and Avro readers are asked to produce, so they enforce the Date range. Paimon DATE is a signed 32-bit day count, which Iceberg and Delta Lake already read as Date32.

The change maps DATE to Date32 at that single site. Table functions, engines, the paimon_rest catalog and the partition pruner take their types from it, and ARRAY/MAP elements follow. Partition values were already read as a signed Int32, the Date32 representation, and partition directory names are built from the raw day count, so pruning and paths need no change. Persisted Paimon* tables reload their columns from the Paimon schema on every query. The documented type mapping is updated in both doc strings. Paimon is experimental, so the mapping is corrected without a compatibility setting, as #119404 did for BOOLEAN.

The new test reads pypaimon-written tables (generator in the fixture README) with the Date and Date32 bounds, NOT NULL, ARRAY<DATE>, ORC and Avro, and a table partitioned by DATE with partitions before 1970 and after 2149, including a pruning check by EngineFileLikeReadFiles. It fails on master with code 321 and passes with the fix (50/50 with random settings). The type expectations of the existing Paimon stateless and integration tests are updated; test_types, test_reader_compat and test_partition_pruning_types of test_storage_paimon_with_spark pass locally.


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

Version info

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

groeneai and others added 2 commits October 30, 2026 23:52
Paimon DATE is a signed 32-bit day count, like Iceberg and Delta Lake
`date`, which are already read as Date32. Paimon::DataType::parse mapped
it to Date, whose range is 1970-01-01 to 2149-06-06, and that type is the
requested column type of the data-file reader. One value outside that
range made every query that reads the column fail:

  Code: 321. DB::Exception: Input value -1 is out of allowed Date range,
  which is [0, 65535] ... (VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE)

while file() on the same Parquet file infers Date32 and reads it.

Map DATE to Date32 at the parse site. Every Paimon surface (paimon*
table functions, Paimon* engines, the paimon_rest DataLakeCatalog, the
partition pruner key) takes its type from there. Partition values were
already read as a signed Int32 (getInt), which is the Date32
representation, and partition directory names are built from that raw
day count, so pruning and paths are unchanged. Persisted Paimon* tables
reload their columns from the Paimon schema on every query, so they
switch to Date32 without DDL.

Paimon is experimental, so the mapping is corrected without a
compatibility setting, as was done for BOOLEAN (ClickHouse#119404).

The new test reads pypaimon-written tables with the Date and Date32
bounds and the days just outside the Date range (nullable, NOT NULL,
ARRAY<DATE>), the same kind of rows in ORC and Avro, and a table
partitioned by DATE with partitions before 1970 and after 2149,
including a pruning check. The type expectations of the existing Paimon
tests are updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Date32 covers 0000-01-01 .. 9999-12-31 since 26.8, so the fixture's
previous 1900-01-01 and 2299-12-31 rows were not its bounds. Regenerate
t_parquet with the real bounds (day numbers -719528 and 2932896), which
are also the bounds of Paimon DATE.

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

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (2 rounds)
  • ⚠️ date32-bounds (Gate B r1, major): the fixture called 1900-01-01 / 2299-12-31 the Date32 bounds, but Date32 covers 0000-01-01 .. 9999-12-31 (also the Paimon DATE range). AGREE: t_parquet regenerated with the real endpoints in 663f6e1; the readers already accept the full range, no source change. Gate B r2 on the new head: no findings.
  • 💡 ORC and Avro Paimon tables are read with the documented format argument, because the reader does not take the format from the table's file.format. Out of scope, not raised.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. DESCRIBE + SELECT over paimonLocal('<fixture>/t_parquet') (or the pypaimon script from #128306) gives d Nullable(Date) and code 321 Input value -719528 is out of allowed Date range on master, every run.
b Root cause explained? Paimon::DataType::parse mapped DATE to Date; that is the target type of the Parquet/ORC/Avro readers, which enforce [0, 65535], so any day before 1970-01-01 or after 2149-06-06 throws.
c Fix matches root cause? Yes. The type is corrected at its only source (DataTypeDate32); no reader, range check or setting is changed.
d Test intent preserved / new tests added? New 05473_paimon_date32 (Date and Date32 bounds, NULL, NOT NULL, ARRAY<DATE>, ORC, Avro, DATE partitions before 1970 and after 2149, pruning by EngineFileLikeReadFiles). Existing Paimon tests change only the type strings Date -> Date32.
e Both directions demonstrated? Yes. The new test fails with code 321 when Types.h is reverted and rebuilt (every arm on its own), passes with the fix; 50/50 with random settings. The updated integration pins fail on master and pass with the fix.
f Fix is general across code paths? One parse site feeds the table functions, the Paimon* engines, the paimon_rest catalog and the partition pruner key. Partition values were already read as signed Int32 and directory names from the raw day count, so d=-1 and d=84006 partitions are read and pruned.
g Fix generalizes across inputs (params/datatypes/wrappers)? Nullable, NOT NULL, ARRAY<DATE> with a NULL element, NULL rows; the Date32 (and Paimon DATE) bounds 0000-01-01 and 9999-12-31, the Date bounds 1970-01-01 and 2149-06-06 and the days just outside them; Parquet, ORC, Avro; DATE partition key. MAP elements use the same recursive parse.
h Backward compatible? (maintainer-approved exception only) The reported type changes to Date32; values in the Date range read and render the same and still insert into an existing Date column. Paimon is experimental, so no compatibility setting, as #119404 did for BOOLEAN. Persisted Paimon* tables reload their columns per query.
i Invariants and contracts preserved? The partition Field (Int32) now matches the key type's storage. Values outside the Date32 range still throw by default, as with file(), Iceberg and Delta Lake.

Session id: cron:clickhouse-impl-slot-41:20261030-233000

@clickhouse-gh

clickhouse-gh Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d488099]

Summary: ❌

job_name test_name status info comment
Storage memory check FAIL
02_insert_data.sql FAIL cidb IGNORED
09_cleanup.sql FAIL cidb IGNORED

AI Review

Summary

PR #128329 maps Paimon DATE to Date32, allowing dates outside the Date range, and updates source documentation and regression coverage. No actionable findings in head d488099cc18da09d4b465b68ee773c908c06bfc9.

Missing context / blind spots
  • ⚠️ Focused Paimon CI results are not yet available for the latest merge commit, and tests were not rerun locally. The previous revision's ASan/UBSan flaky check passed all 200 runs, including 50 runs of 05473_paimon_date32. Completion of the latest focused CI jobs would close this validation gap.
Final Verdict

Status: ✅ Approve

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @JiaQiTang98 @hanfei1991, could you review this and add the can be tested label so CI runs? Paimon DATE is a signed 32-bit day count, but Paimon::DataType::parse mapped it to Date, so the readers enforced the Date range and any day before 1970 or after 2149 failed the whole read with code 321; it now maps to Date32, as Iceberg and Delta Lake do.

@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 d488099cc with master c189bd99f (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 1ee49128d; 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.

Compile time of recompiled translation units

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

Job report

The flaky check runs a changed test many times concurrently against one
server. 03701 copied its fixture into the shared
user_files/data_minio/paimon_no_partition, so concurrent `cp -r` calls
raced on the same destination and failed with
`cp: cannot create regular file ... File exists` (1 of 250 runs in
`Stateless tests (amd_asan_ubsan, flaky check)`; 2 of 50 locally with
`--test-runs 50 --jobs 16`). Copy into CLICKHOUSE_USER_FILES_UNIQUE and
remove it at the end, as 04749 already does. The reference is unchanged.

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

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 888ed62

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
Stress test (amd_tsan) / ThreadSanitizer: data race (STID: 3766-2b51) not from this PR (it changes only the Paimon DATE type mapping and its tests): the embedded SSH client writes its exit code (ClientEmbeddedRunner.cpp:80) while SSHPtyHandler reads it (ClientEmbeddedRunner.cpp:25). The fix makes exit_code atomic; it merged after this run started, and the tested merge tree 1b501e7377e9 does not contain it. Seen on 3 other PRs since 2026-10-29 #127990 (mine, merged)
Mergeable Check, PR praktika rollups of the row above #127990 (the owner of the row above)

CIDB has no other FAIL or ERROR row on this head.

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

@groeneai

groeneai commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - d488099

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
Storage memory check / 02_insert_data.sql, 09_cleanup.sql flaky, not from this PR (it changes only the Paimon DATE type mapping, and the earlier heads were +0 here): 02_insert_data.sql +12,296 B (1.3%), still live after 09_cleanup.sql (+12,112 B). The cross-version diff is ZSTD compression-context workspaces (ZSTD_cwksp_create, +40,960 / -28,672 B). An unrelated PR got the same ~12.4 KB on the master arm 8 minutes later (report) 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 one owning the row above)

CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261101-133004

@groeneai

groeneai commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Storage memory check row of the d488099 ledger: #128485 (the scenario inserted now(), so near the start of a month test_mt got two partitions).

@fm4v
fm4v added this pull request to the merge queue Nov 2, 2026
Merged via the queue into ClickHouse:master with commit 5109533 Nov 2, 2026
177 of 179 checks passed
@fm4v fm4v self-assigned this Nov 2, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 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 DATE is read as Date instead of Date32: dates before 1970 or after 2149 fail with VALUE_IS_OUT_OF_RANGE_OF_DATA_TYPE

4 participants