Skip to content

Map Paimon BOOLEAN to Bool instead of Int8 - #119404

Merged
JiaQiTang98 merged 10 commits into
ClickHouse:masterfrom
JiaQiTang98:fix-paimon-boolean-type
Sep 22, 2026
Merged

JiaQiTang98 merged 10 commits into
ClickHouse:masterfrom
JiaQiTang98:fix-paimon-boolean-type

Conversation

@JiaQiTang98

@JiaQiTang98 JiaQiTang98 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

The Paimon schema layer mapped Paimon BOOLEAN to Int8, while Iceberg and Delta Lake both map their boolean to Bool, and reading the very same data file with the file table function infers Nullable(Bool).

The values were read correctly, but the reported type was wrong:

  • Any text rendering of the column produced 0/1 instead of false/true — toString, SELECT output, JSONEachRow, formatRow. This is what surfaced the problem: a cross-engine consistency check that hashes CAST(col AS STRING) on the Spark side against toString(col) on the ClickHouse side reported a data mismatch for a table whose data is identical.
  • toTypeName and DESCRIBE misreported the column, so downstream tooling could not tell a Paimon BOOLEAN apart from a Paimon TINYINT — both were Int8.

Bool is UInt8 with a custom name and has no data type class of its own, so it is taken from DataTypeFactory, the same way Iceberg/SchemaProcessor.cpp and DeltaLakeMetadata.cpp do it. Nested types go through the same recursive DataType::parse, so Array(BOOLEAN) and a BOOLEAN map value are covered too.

The partition paths in Paimon/Utils.cpp need no change: getPartitionFields builds a Field from a bool, which matches the UInt8 underlying Bool, and getPartitionString spells the directory name from the raw Paimon bit independently of the ClickHouse type. f_boolean is a partition key of the paimon_all_types dataset, so Bool also has to work as a PartitionPruner key type. 03714_paimon_partition_pruning and 03775_paimon_partition_pruning_storage cover it through f_boolean IS NOT NULL and their ProfileEvents assertions are unchanged by this PR; the new test adds the boolean-literal case. Pruning is result-preserving, so equal row counts alone would also pass for a pruner that stopped recognizing a Bool literal and fell back to a full scan. The test therefore asserts ProfileEvents['EngineFileLikeReadFiles'] per query, correlated by log_comment: for WHERE f_boolean = false it drops from the ten files of the table to the five matching partitions.

The BOOLEAN row of the documented type mapping is updated in both doc strings it is generated from. The generated paimon.mdx pages are left to the documentation autogeneration workflow.

Note that this changes the text rendering of Paimon BOOLEAN columns from 0/1 to false/true. The Paimon engine is still experimental, and the previous mapping was inconsistent with Iceberg, Delta Lake and with a direct read of the underlying data file, so the mapping is corrected unconditionally rather than kept behind a compatibility setting.

Closes: #119272
Related: #84423

Changelog category (leave one):

  • Improvement

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

Paimon BOOLEAN columns are now read as Bool instead of Int8, matching Iceberg and Delta Lake. DESCRIBE and toTypeName now report Bool, and text formats render the values as false/true instead of 0/1.


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

Version info

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

The Paimon schema layer mapped Paimon `BOOLEAN` to `Int8`, while Iceberg and
Delta Lake both map their `boolean` to `Bool`, and reading the very same data
file with the `file` table function infers `Nullable(Bool)`.

The values were read correctly, but the reported type was wrong:

* Any text rendering of the column produced `0`/`1` instead of `false`/`true` -
  `toString`, `SELECT` output, `JSONEachRow`, `formatRow`. This is what
  surfaced the problem: a cross-engine consistency check that hashes
  `CAST(col AS STRING)` on the Spark side against `toString(col)` on the
  ClickHouse side reported a data mismatch for a table whose data is identical.
* `toTypeName` and `DESCRIBE` misreported the column, so downstream tooling
  could not tell a Paimon `BOOLEAN` apart from a Paimon `TINYINT` - both were
  `Int8`.

`Bool` is `UInt8` with a custom name and has no data type class of its own, so
it is taken from `DataTypeFactory`, the same way `Iceberg/SchemaProcessor.cpp`
and `DeltaLakeMetadata.cpp` do it. Nested types go through the same recursive
`DataType::parse`, so `Array(BOOLEAN)` and a `BOOLEAN` map value are covered
too.

The partition paths in `Paimon/Utils.cpp` need no change: `getPartitionFields`
builds a `Field` from a `bool`, which matches the `UInt8` underlying `Bool`, and
`getPartitionString` spells the directory name from the raw Paimon bit
independently of the ClickHouse type. `f_boolean` is a partition key of the
`paimon_all_types` dataset, so `Bool` as a `PartitionPruner` key type is
exercised by `03714_paimon_partition_pruning` and
`03775_paimon_partition_pruning_storage`, whose `ProfileEvents` assertions are
unchanged.

The `BOOLEAN` row of the documented type mapping is updated in both doc strings
it is generated from. The generated `paimon.mdx` pages are left to the
documentation autogeneration workflow.

Closes: ClickHouse#119272
@clickhouse-gh

clickhouse-gh Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [01c5d59]

Summary: ✅


AI Review

Summary

This PR corrects Paimon BOOLEAN schema mapping from Int8 to Bool, updates the structured documentation sources, refreshes the existing result files, and adds focused coverage for type reporting, text rendering, and boolean-literal partition pruning. I did not find any remaining correctness, compatibility, or coverage issues in the current head.

Final Verdict

✅ No new findings.

LLVM Coverage Report

Measured on commit 01c5d59.

Metric Baseline Current Δ
Lines 88.00% 88.00% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.30% 79.30% +0.00%

Changed lines: Changed C/C++ lines covered: 16/16 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Sep 11, 2026
@JiaQiTang98 JiaQiTang98 added the can be tested Allows running workflows for external contributors label Sep 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 01c5d59fb with master c22d746de (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.

Compile time of recompiled translation units

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

Job report

@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@maxknv maxknv removed the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@maxknv maxknv removed the external Author is not a member of the ClickHouse organization label Sep 11, 2026
@JiaQiTang98 JiaQiTang98 added pr-improvement Pull request with some product improvements and removed pr-bugfix Pull request with bugfix, not backported by default labels Sep 11, 2026
@PedroTadim

Copy link
Copy Markdown
Member

Had to fix something in the sync PR, doing one more CI run

@clickhouse-gh

clickhouse-gh Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 37 queries analysed

no significant changes detected. K_source=6 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 8976199c-e15a-4ff1-af42-47149817bffd
  • MIRAI run: 6a0c6e40-2460-4869-9513-4a525be92a37
  • PR check IDs:
    • clickbench_1288208_1790055352
    • clickbench_1288214_1790055352
    • clickbench_1288220_1790055352
    • tpch_adapted_1_official_1288232_1790055352
    • tpch_adapted_1_official_1288244_1790055352
    • tpch_adapted_1_official_1288279_1790055353

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
alexey-milovidov and others added 2 commits September 19, 2026 20:41
The pruning-on/off pair filtered on `f_boolean_nn`, which is not a partition
column, and the two `countIf` queries that carried the pruning setting had no
WHERE clause at all - so no query reached `PartitionPruner` with a `Bool`
literal and the changed pruning path stayed unproven.

The pair now filters on `f_boolean`, the partition key (see the first pair of
`03714_paimon_partition_pruning`, where pruning on it cuts the files read from
10 to 5). The pruning setting is dropped from the `countIf` query, where it did
nothing, and the plain-`Bool` literal check on `f_boolean_nn` is kept as a
single query.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@PedroTadim
PedroTadim added this pull request to the merge queue Sep 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 20, 2026
`05137_paimon_boolean_type` compared only the row counts of
`WHERE f_boolean = false` with and without `use_paimon_partition_pruning`.
Pruning is result-preserving, so two equal counts only rule out
over-pruning: a `PartitionPruner` that stopped recognizing a `Bool`
literal and fell back to a full scan would still pass.

Assert `ProfileEvents['EngineFileLikeReadFiles']` per query instead,
correlated by `log_comment` the way `02346_text_index_bug108519_qcc_skip_index`
does, and compare the result sets as well: the ten files of
`paimon_all_types` without pruning against the five matching partitions
with it. `no-parallel-replicas` is needed for the same reason as in
`03714_paimon_partition_pruning` - the coordinator does not collect all
`ProfileEvents` values.

Reported by the AI review of
ClickHouse#119404 (comment)
@JiaQiTang98
JiaQiTang98 added this pull request to the merge queue Sep 22, 2026
Merged via the queue into ClickHouse:master with commit 9d2b2e7 Sep 22, 2026
177 checks passed
@JiaQiTang98
JiaQiTang98 deleted the fix-paimon-boolean-type branch September 22, 2026 08:43
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 22, 2026
Blargian pushed a commit to theory/ClickHouse that referenced this pull request Nov 2, 2026
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]>
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 BOOLEAN columns are read as Int8 instead of Bool, unlike Iceberg and Delta Lake

5 participants