Repository navigation
Give a clear error when a Hive partition value does not fit the type of its partition column - #131202
Conversation
…n type `convertFieldToType` returns `Null` for a value outside the range of the target type. The two places that materialize a Hive partition value from the path, `HivePartitioningUtils::addPartitionColumnsToChunk` and the Hive branch of `VirtualColumnUtils::addRequestedFileLikeStorageVirtualsToChunk`, passed that result straight to `createColumnConst`. For a type that cannot hold NULL the column insert then failed with `BAD_GET` (`UInt8` with `k0=300` or `k0=-1`, `Array(UInt8)` with `k0=[256]`, `Tuple`, ...), and for `LowCardinality(UInt8)` with the `LOGICAL_ERROR` "ColumnUnique can't contain null values". Both sites now call `HivePartitioningUtils::convertPartitionValueToType`, which throws `TYPE_MISMATCH` naming the value, the path, the type and the column when the result is `Null` and `canContainNull(type)` is false. That is the error class an unparsable value already gets. `Nullable` and `LowCardinality(Nullable)` keep reading such a value as NULL; `Variant` and `Dynamic` are unchanged. `convertFieldToTypeOrThrow` is not reused: it also throws for a `Nullable` target, and its message names neither the column nor the path. The path pre-filter (`addPathAndFileToVirtualColumns`) parses values with text deserialization rather than `convertFieldToType`, so it does not hit this error, and is left unchanged. Closes ClickHouse#131087 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 2 rounds, 2 findings in round 1, none in round 2) plus my own review.
Round 2 (same code, corrected text): no findings. Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261113-064800 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261113-052600 |
|
Workflow [PR], commit [e47914a] Summary: ✅
AI ReviewSummaryPR #131202, reviewed at Missing context / blind spots
Final VerdictStatus: ✅ Approve. No review changes required. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units20 translation units recompiled, 175 s compile time in total, 20 of them have a recent master baseline. |
3a97622
Closes: #131087
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A Hive partition value that does not fit the type of its partition column (for example
k0=300fork0 UInt8) now gives aTYPE_MISMATCHerror that names the value, the path and the column, instead ofBAD_GET(or aLOGICAL_ERRORforLowCardinality). Closes #131087.Description
With
use_hive_partitioning = 1, a path value that the declared type of its partition column cannot hold (k0=300ork0=-1forUInt8,k0=[256]forArray(UInt8)) failed withBad get: has Null, requested UInt64 (BAD_GET), and forLowCardinality(UInt8)with theLOGICAL_ERRORColumnUnique can't contain null values(an abort in a debug build).convertFieldToTypereturnsNullfor a value outside the range of the type, and both places that materialize a Hive partition value passed it straight tocreateColumnConst:HivePartitioningUtils::addPartitionColumnsToChunk(thefile,url, object storage andS3Queue/AzureQueuereaders) and the Hive branch ofVirtualColumnUtils::addRequestedFileLikeStorageVirtualsToChunk(a partition column that is not in the structure).Both now call
HivePartitioningUtils::convertPartitionValueToType, which throwsTYPE_MISMATCH(Cannot convert '300' from the path <path> to type UInt8 for the Hive partition column k0) when the result isNulland the type cannot contain NULL, the same error class an unparsable value (k0=abc) already gets.NullableandLowCardinality(Nullable)still read such a value as NULL;VariantandDynamicare unchanged. Only queries that already failed change. The path pre-filter forWHEREon a partition column is unchanged: it parses the value with text deserialization, notconvertFieldToType, so this error does not apply there (for such a value it can disagree with the reader, a separate problem not changed here).Validation: the new test
05628_hive_partitioning_value_out_of_rangecovers the boundary value, both range ends,Array,LowCardinality, the NULL cases, the virtual column and thes3reader. Every error line fails on master (BAD_GET, or the abort) and passes with the fix; 50/50 randomized runs pass.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131202]
Version info
26.11.1.2211-master(included in26.11and later)