Repository navigation
Map Paimon BOOLEAN to Bool instead of Int8 - #119404
Conversation
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
|
Workflow [PR], commit [01c5d59] Summary: ✅
AI ReviewSummaryThis PR corrects Paimon Final Verdict✅ No new findings. LLVM Coverage ReportMeasured on commit 01c5d59.
Changed lines: Changed C/C++ lines covered: 16/16 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units30 translation units recompiled, 298 s compile time in total, 30 of them have a recent master baseline. |
|
Had to fix something in the sync PR, doing one more CI run |
|
📊 Cloud Performance Report ✅ AI verdict: 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
|
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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]>
`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)
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]>
The Paimon schema layer mapped Paimon
BOOLEANtoInt8, while Iceberg and Delta Lake both map theirbooleantoBool, and reading the very same data file with thefiletable function infersNullable(Bool).The values were read correctly, but the reported type was wrong:
0/1instead offalse/true—toString,SELECToutput,JSONEachRow,formatRow. This is what surfaced the problem: a cross-engine consistency check that hashesCAST(col AS STRING)on the Spark side againsttoString(col)on the ClickHouse side reported a data mismatch for a table whose data is identical.toTypeNameandDESCRIBEmisreported the column, so downstream tooling could not tell a PaimonBOOLEANapart from a PaimonTINYINT— both wereInt8.BoolisUInt8with a custom name and has no data type class of its own, so it is taken fromDataTypeFactory, the same wayIceberg/SchemaProcessor.cppandDeltaLakeMetadata.cppdo it. Nested types go through the same recursiveDataType::parse, soArray(BOOLEAN)and aBOOLEANmap value are covered too.The partition paths in
Paimon/Utils.cppneed no change:getPartitionFieldsbuilds aFieldfrom abool, which matches theUInt8underlyingBool, andgetPartitionStringspells the directory name from the raw Paimon bit independently of the ClickHouse type.f_booleanis a partition key of thepaimon_all_typesdataset, soBoolalso has to work as aPartitionPrunerkey type.03714_paimon_partition_pruningand03775_paimon_partition_pruning_storagecover it throughf_boolean IS NOT NULLand theirProfileEventsassertions 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 aBoolliteral and fell back to a full scan. The test therefore assertsProfileEvents['EngineFileLikeReadFiles']per query, correlated bylog_comment: forWHERE f_boolean = falseit drops from the ten files of the table to the five matching partitions.The
BOOLEANrow of the documented type mapping is updated in both doc strings it is generated from. The generatedpaimon.mdxpages are left to the documentation autogeneration workflow.Note that this changes the text rendering of Paimon
BOOLEANcolumns from0/1tofalse/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):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Paimon
BOOLEANcolumns are now read asBoolinstead ofInt8, matching Iceberg and Delta Lake.DESCRIBEandtoTypeNamenow reportBool, and text formats render the values asfalse/trueinstead of0/1.Workflow [PR]
Sync PR [sync-upstream/pr/119404]
Version info
26.10.1.404-master(included in26.10and later)