Repository navigation
Add coverage for the HASHED_ARRAY SHARDS/UPDATE_FIELD guard and arrayShift* insertManyFrom specializations - #114287
Conversation
…ft* insertManyFrom specializations Re-files the coverage of two closed clickgapai PRs (ClickHouse#103884, ClickHouse#103913) that @ zlareb1 asked to be re-opened, with the gap claims narrowed to what I could measure and the oracles mutation-tested. 04146_hashed_array_dictionary_shards_update_field pins src/Dictionaries/HashedArrayDictionary.cpp:1265, which rejects SHARDS > 1 on an UPDATE_FIELD source. A textually identical guard at src/Dictionaries/registerHashedDictionary.cpp:89 serves HASHED/SPARSE_HASHED and is already covered by 02391_hashed_dictionary_shards; the HASHED_ARRAY copy was not covered by anything. Mutating :1265 alone reddens the new test while 02391 stays green, which is what attributes the coverage to the right copy. The complex-key block of the original test is not kept: registerLayout("hashed_array") and ("complex_key_hashed_array") call the same create_layout lambda and the guard precedes the DictionaryKeyType branch, so both key forms are one carrier. 04201_array_shift_insert_many_from_specializations pins the insertManyFrom overrides of ColumnFixedString, ColumnDecimal, ColumnNullable, ColumnTuple and ColumnMap through the two arrayShiftRotate.cpp call sites. Master's only arrayShift* test uses UInt8/String/Array element types, so this call site was untested for these five. Five defects in the adopted ClickHouse#103913 are fixed here. Its JOIN block claimed HashJoin reaches insertManyFrom; isolated and re-run with ColumnFixedString::insertManyFrom corrupted, that block still passes, so it never reaches the override and is dropped. Its Nullable rows passed a non-NULL default, leaving the null map unexercised; an explicit NULL default does not reach the null map at all, so the omitted-default form is asserted alongside, and the two ColumnNullable carriers now redden disjoint row sets. Its "no existing test exercises these specializations" claim is false: 01019_array_fill reddens under both ColumnNullable mutations and 02411_legacy_geobase under the ColumnTuple and ColumnMap ones, so only the arrayShift* call site is new. Two fixtures used the type's own default as the distinctive default, hiding an insert-defaults mutation. Every query was single-row, so insertManyFrom's position argument was always 0 and an override ignoring it would have passed; the fixtures are multi-row with per-row defaults, and a mutation hardcoding position = 0 reddens them. Mutations change each branch's output rather than deleting it, because deleting any of these overrides falls through to IColumn::insertManyFrom's insertFrom loop and produces identical output. The third PR of the group, ClickHouse#103920, is not re-filed. isShortCircuit has no layout and no arity branch, and both regression directions at FunctionsExternalDictionaries.h:361 are already pinned by 02950_dictionary_short_circuit.sql:28 and 03009_range_dict_get_or_default.sql:29.
…ap comment The guard at src/Dictionaries/HashedArrayDictionary.cpp:1265 rejects SHARDS > 1 on an UPDATE_FIELD source, so its threshold is 1. The test bracketed 1 (accepted) against SHARDS 10 (rejected), which left the 2..9 range unpinned: a regression moving the threshold anywhere into that range kept both assertions green while wrongly admitting those values. The rejected value now sits on the guard's exact negative boundary. That is strictly tighter and reaches no other decision, because the throw precedes the shards > 1 template dispatch at :1279-1289 and 2 is inside the [1, 128] range check at :1258. A new mutation arm moving the threshold to shards > 9 reddens the test, and the matching negative control shows the old SHARDS 10 fixture stays green under that same mutation, so the tightening is what added the coverage rather than the test merely reacting to some mutation. The two existing arms were re-run against the new fixture and still redden this test while 02391_hashed_dictionary_shards stays green, so attributing the coverage to this guard copy rather than the identical one at registerHashedDictionary.cpp:89 still holds. The null-map comment in 04201_array_shift_insert_many_from_specializations said the omitted default is the only shape that fills the null map from the default. ColumnNullable::insertManyFrom always copies the null map from the default column, so an explicit default contributes FALSE bits and the omitted form is the only shape contributing TRUE bits. An explicit Nullable default cannot supply NULL bits at all: the result type is Array, which is not canBeInsideNullable, so the default is denulled and its NULL rows are overwritten by insertDefault before executeImpl runs.
Internal second-model reviewReviewed cold against the resulting tests, then adjudicated with the recorded evidence. Two ❌
The review also asked for a dispatch or performance oracle that would fail if a specialized Two claims in my own description were also corrected before posting: the residual at the end cited |
Pre-PR validation
Mutations change each branch's output rather than deleting it: deleting any of these overrides falls through to 216 runs green: 50 of each test with randomized settings (the CI default), 50 with |
|
cc @nihalzp, could you review this? It adds two coverage tests: one pinning the HASHED_ARRAY guard that rejects SHARDS > 1 on an UPDATE_FIELD source (only the textually identical HASHED/SPARSE_HASHED copy was covered), and one pinning the insertManyFrom overrides of ColumnFixedString, ColumnDecimal, ColumnNullable, ColumnTuple and ColumnMap through arrayShift*, where multi-row per-row-default fixtures are what make a nonzero position observable. |
|
Workflow [PR], commit [a4471a7] Summary: ❌
AI ReviewSummaryThis PR adds two focused stateless coverage tests: one for the Final Verdict✅ No findings. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline. |
CI finish ledger - a4471a7CI is fully finished on this head: 175 checks completed, 39 success, 135 skipped (each with a
I parsed Not PR-caused: this PR changes only four stateless test files (two Session id: cron:our-pr-ci-monitor:20260811-223000 |
9678956
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
@ zlareb1 asked me to re-file a batch of closed coverage PRs (his ask). This is the dictionaries/columns group. Related: #103884, #103913, #103920.
Two new tests:
04146_hashed_array_dictionary_shards_update_fieldpinsHashedArrayDictionary.cpp:1265, which rejectsSHARDS > 1on anUPDATE_FIELDsource. A textually identical guard atregisterHashedDictionary.cpp:89servesHASHED/SPARSE_HASHEDand is covered by02391_hashed_dictionary_shards; theHASHED_ARRAYcopy was not covered.04201_array_shift_insert_many_from_specializationspins theinsertManyFromoverrides ofColumnFixedString,ColumnDecimal,ColumnNullable,ColumnTupleandColumnMapthrougharrayShiftRight/arrayShiftLeft. Master's onlyarrayShift*test usesUInt8/UInt16/String/Arrayelement types, so this call site was untested for these five.Every assertion was mutation-tested: corrupt the cited line, confirm the test reddens, revert, confirm it passes. That found five defects in the adopted #103913, all fixed here (details below).
I am not re-filing #103920. Its oracle is sound, but
isShortCircuithas no layout or arity branch (FunctionsExternalDictionaries.h:356-368) and both regression directions are already pinned, verified by mutation:02950_dictionary_short_circuit.sql:28catches losing the- 1,03009_range_dict_get_or_default.sql:29catches a revert to the pre-fix set. Reasoning is on that PR.Validation
Baseline: 7 tests (2 new + 5 controls) pass,
rc == 0and verdictOKper test.HashedArrayDictionary.cpp:1265, both directions0414602391(the other guard copy)FunctionsExternalDictionaries.h:361drops- 102950(DIVISION_BY_ZERO)030090300902950arrayShiftRotate.cpp:213+:219position-> 004201,02845ColumnFixedString.cpp:1180420100436ColumnDecimal.h:6904201ColumnNullable.cpp:320/:32104201ColumnTuple.cpp:319/ColumnMap.cpp:2160420102845,01019Mutations change each branch's output rather than deleting it: deleting any override falls through to
IColumn::insertManyFrom'sinsertFromloop and produces identical output, leaving a vacuous test green.Five defects found in the adopted #103913 and fixed here:
insertManyFrom. It does not: withColumnFixedString::insertManyFromcorrupted, the JOIN block alone still passes. Cut.Nullablerows passed a non-NULL default, so the null-map line was never exercised.01019_array_fillreddens under bothColumnNullablemutations,02411_legacy_geobaseunder theColumnTuple/ColumnMapones. Only thearrayShift*call site is new.positionwas always 0 and an override ignoring it would have passed. Fixtures are now multi-row with per-row defaults.216 runs green: 50 of each test with randomized settings (the CI default), 50 with
--no-random-settings, and 8 concurrent copies over 4 jobs. Nono-paralleltag and no settings clamp needed.Separately,
arrayShiftRight([1::Nullable(Int64),2,3], 2, NULL::Nullable(Int64))returns[0,0,1]rather than NULLs, whilearrayResizewith the same default returns[1,2,NULL,NULL]. The 2-argument form is correct. Not fixed here.