Repository navigation
Conversation
Four key-analysis sites open with the same six-line prologue: walk a `const IDataType &` through a `LowCardinality` wrapper, then through a `Nullable` wrapper, by raw pointer, using `typeid_cast`, in that order. Two reviewers pointed at it independently on ClickHouse#112339. The duplication exists because `src/DataTypes/` exposed the unwrap only in `DataTypePtr` form. `IFunction::getMonotonicityForRange` receives a reference, and `IDataType::getPtr()` is `shared_from_this()`, which throws for a type not owned by a `shared_ptr`, so those callers could not reach `removeLowCardinalityAndNullable` and open-coded the walk instead. This adds the missing raw-pointer overload beside the existing one and converts the four `src/Functions` copies. `negate` read the nullability of the original type mid-walk, which the helper does not expose. It is recovered without a second walk as `isNullable() || isLowCardinalityNullable()`; `DataTypeLowCardinality` reports the former as false and delegates the latter to its dictionary, so the two spellings agree on all four wrapper shapes. No behaviour change. Two of the four converted sites spelled the casts as `checkAndGetDataType`, which is a one-line alias for `typeid_cast`. A deferred carrier, `KeyCondition.cpp:2847`, spells the second strip as `isNullable()` plus `static_cast`, equivalent because `DataTypeNullable::isNullable()` is a `final` `true`; that will matter when that site is converted. Coverage: only the `FunctionBinaryArithmetic` site was pinned, by `04652_compound_key_monotonicity`. No stateless test combined a `negate`/`toDayOfWeek`/date-transform key with a `LowCardinality` or `Nullable` wrapper and asserted pruning, so a wrong unwrap at the other three landed green. `04747_unwrap_monotonicity_dedup` adds that pin. Six mutants (swap the strips, drop either strip, hard-`false` the recovered `is_nullable`, revert either header's unwrap) each fail it 20 out of 20 randomized runs, and it passes on unmodified master, as a characterization test should. Two settings are pinned per query rather than jointly. Half of all runs draw `optimize_read_in_order = 0`, which disables the sort optimization that is the only observable of the `negate` verdict. And 40 percent draw `use_lightweight_primary_key_index_analysis = 0`, where the index analysis hands the transform a key type that `recursiveRemoveLowCardinality` has already stripped (`KeyCondition.cpp:5532`); the sparse branch passes it raw (`:5973`). Both branches consult the transform's monotonicity, but only the raw one can observe a wrong unwrap of the `LowCardinality` half, which is why the two `LowCardinality`-half mutants were the ones that under-reddened before the pin. Both settings read identical values on unmodified code, so they remove an escape hatch rather than weaken an assertion.
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings across two passes;
Severity: ❌ blocker / Also verified by reading, at all four converted sites: Session id: cron:clickhouse-review-slot-54:20260805-110002 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-54:20260805-110002 |
|
cc @Avogar @rschu1ze, could you review this? It adds a raw-pointer overload of |
|
Workflow [PR], commit [21bebbe] Summary: ❌
AI ReviewSummaryThis PR adds a raw-pointer overload of Final Verdict✅ No review findings. LLVM Coverage ReportMeasured on commit 21bebbe.
Changed lines: Changed C/C++ lines covered: 19/19 (100.00%) · Uncovered code |
CI finish ledger - 1506ca1Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Notes on the one line above, since it is easy to misread as green:
Nothing here is attributable to this PR's diff, which touches Session id: cron:our-pr-ci-monitor:20260805-180000 |
Every `DROP TABLE IF EXISTS` in `04747_unwrap_monotonicity_dedup.sql` carried `SETTINGS ignore_drop_queries_probability = 0`. The setting defaults to 0 and only two jobs ever set it - the stress test (0.2) and the upgrade check (1, via `--fake-drop`) - and neither compares a stateless test's per-test output, so the clause cannot affect any job that checks results. @ alexey-milovidov asked for these pins to be removed (ClickHouse#112005), and ClickHouse#113117 has since deleted every one of them from master. Keeping them on this branch would re-add a setting a maintainer has just removed. The removal is textually exact: the file is byte-identical to its previous content with only the trailing clause dropped from the 20 `DROP` lines, and the `.reference` is untouched because this test does not use `-- { echo }`.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1043 translation units recompiled, 7825 s compile time in total, 1043 of them have a recent master baseline. |
CI finish ledger - 21bebbeEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260905-060038 |
Related: #112339
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
No behaviour change. This is the deduplication @PedroTadim and @Ergus both asked for on #112339,
which merged before I could apply it.
Four key-analysis sites open with the same prologue: walk a
const IDataType &through aLowCardinalitywrapper, then aNullablewrapper, by raw pointer, in that order.src/DataTypes/exposed that unwrap only inDataTypePtrform, andIFunction::getMonotonicityForRangereceives a reference whileIDataType::getPtr()throws for atype not owned by a
shared_ptr- so those callers could not useremoveLowCardinalityAndNullableand copied the walk instead. I add the missing raw-pointer overload beside it and convert
FunctionBinaryArithmetic.h:3841,negate.cpp:43,IFunctionCustomWeek.h:47andIFunctionDateOrDateTime.h:129.Correcting my earlier count in that thread: there are 4 copies under
src/Functions, not 2, and 8 insrc/. I had missed the twoIFunction*headers because they spell the castscheckAndGetDataType, which is a one-line alias fortypeid_cast(FunctionHelpers.h:26-29).Four carriers are deliberately left alone:
KeyCondition.cpp:1789and:2843(hottest file in keyanalysis, several open PRs touching it),
SetUtils.cpp:34(holds aDataTypePtrand can just callthe existing function - a separate cleanup), and
PNGSerializer.cpp:73(#112846 rewrites that file,and its
removeLowCardinalityTypehalf is also used alone at:93).As stated in that thread, the test after the prologue stays different per site.
isCompoundForMonotonicityasksisArray || isTuple || isMap;negate.cpp:54asks!isValueRepresentedByNumber(). Those are not complements -DataTypeNullablehas no override andthe default is false - and
04652_compound_key_monotonicity.sql:219-224pins why unifying them iswrong: a
Stringkey with+ INTERVAL 1 DAYprunes today.Only the first site was pinned against a silent regression, so this adds
04747_unwrap_monotonicity_dedup. Six mutants each fail it 20 of 20 randomized runs; it passes onunmodified master, as a characterization test should.
Mutation matrix and the randomization pins
Each arm is a separate build;
deterministicis--no-random-settings,randomized20 runs withrandomization on.
negate.cpp: force the recoveredis_nullablefalseIFunctionCustomWeek.h's unwrapIFunctionDateOrDateTime.h's unwrapM4 is the interesting one: under it the two
negate ... ORDER BYrows return empty where theLogoracle returns the five expected values, so that arm catches wrong results, not lost pruning.
Two settings are pinned per query.
optimize_read_in_orderis randomized 0/1, and at 0 the sortoptimization that is the only observable of the
negateverdict is off - which made M4 pass 10/10before the pin.
use_lightweight_primary_key_index_analysisis randomized with p=0.6, and at 0 theindex analysis hands the transform a key type that
recursiveRemoveLowCardinalityalready stripped(
KeyCondition.cpp:5532), where the sparse branch passes it raw (:5973) - so a mutant breakingonly the
LowCardinalityhalf of the unwrap is invisible there. Hence the twoLowCardinality-halfmutants are exactly the ones that under-reddened: M1 13/20, M3 6/20 before the pin. Both settings
read identical values on unmodified code, so the pins remove an escape hatch rather than weaken an
assertion.
Rows that cannot move either way are labelled controls in the file:
LowCardinalitydelegatesisValueRepresentedByNumberto its dictionary, andtoStartOfMonthhas aZeroTransformfactor, soit returns before the unwrap.
Workflow [PR]
Sync PR [sync-upstream/pr/113458]