Repository navigation
Fix rows dropped by key analysis when a DateTime constant's declared timezone differs from the key column's - #113781
Conversation
A MergeTree key expression that applies a timezone-observing function to a
DateTime column silently dropped rows when an IN-subquery element's type
declared a different timezone than the key column's:
SET session_timezone = 'Asia/Kolkata';
CREATE TABLE t (ts DateTime('UTC'))
ENGINE = MergeTree PARTITION BY toYYYYMM(ts) ORDER BY tuple();
INSERT INTO t SELECT toDateTime(1675195200, 'UTC');
SELECT count() FROM (SELECT ts FROM t WHERE ts IN (SELECT toDateTime(1675195200)));
returned 0 where 1 is correct. No error, no Nullable, no cross-type width
change; the same instant read from a Memory table returns 1.
applyDeterministicDagToColumn normalizes a set element to the type the DAG
was built against, guarded by !input_type->equals(*dag.input_type). But
DataTypeDateTime::equals deliberately ignores the timezone, on the grounds
that types differing only in timezone are interchangeable, and
DataTypeDateTime64::equals compares only the scale. So the guard evaluated
false, the normalization was skipped, and the block handed to the DAG carried
the element's type. A timezone-observing function resolves its timezone from
that type at execute time, via extractTimeZoneFromFunctionArguments, falling
back to DateLUT::instance() when the type declares none. toYYYYMM therefore
computed 202302 under the session zone where the key's own zone gives 202301.
The row is physically in 202301, so the transformed value named a partition
the row is not in and pruning discarded the only part holding it.
Adopt dag.input_type for a DateTime or DateTime64 input whose type is
equals-equal to the DAG's, testing the family through removeNullable because
DataTypeNullable::equals delegates to the nested type and so hides the timezone
one wrapper up in exactly the same way. equals() being true is exactly the
guarantee that they share a physical representation, so this is a relabel
rather than a conversion: only the local DataTypePtr moves, the column is never
re-materialized, nothing can fail and no NULL can be introduced. The relabel
fires only where the existing !equals guard was already false, so it changes
no branch decision in either direction. On the path that guard would otherwise
take, canBeSafelyCast is true for an equals-equal pair, so the cast is
castColumnAccurate, and castColumn returns the argument column untouched for
such a pair unless the cast is accurateOrNull; the relabel is that same
guarantee stated as code. There is no measurable cost either way: it is one
shared_ptr assignment, once per set index or constant preparation.
Relabeling the whole equals-equal pair, rather than rebuilding the type inside
the wrapper, is what keeps that argument intact: equals() on a Nullable already
guarantees both sides are Nullable over equals-equal nested types, so only the
nested label moves and the wrapper structure is identical. The corrected zone
still reaches the transform, because useDefaultImplementationForNulls is on by
default and its wrapper unwraps through columnGetNested, which takes the nested
DataTypePtr straight off the DataTypeNullable. A LowCardinality(Nullable(...))
key is covered by the existing removeLowCardinality on the line above, and was
measured correct on both arms for a different reason: DataTypeLowCardinality
reports isNullable() false, so such an element never becomes the Nullable pair
this guard sees. Array and Tuple delegate equals() to their nested types too,
but a set element of those types is not a DateTime input to a key transform and
both shapes were measured correct on both arms.
The timezone is not the only attribute equals() is blind to, but it is the
only one where relabeling is sound, so the change is restricted to it rather
than adopting dag.input_type unconditionally. IDataType::custom_name is
equally invisible to equals(), and relabeling there is not
semantics-preserving: Bool is UInt8 plus a custom name whose serialization
renders every nonzero value as true, so a bare-UInt8 element relabeled to
Bool would collapse the transform's value map. toString reports itself
injective, neither caller then marks the condition relaxed, and an exact
NOT IN prunes the partition holding the matching row -- trading this bug for
a wrong-results bug on negative predicates. Measured: with the relabel
unrestricted, b NOT IN (SELECT 2::UInt8) over a two-partition Bool table
returns 1 where 2 is correct. Restricting it to DateTime and DateTime64 keeps
the pruning fix, because relabeling a DateTime type changes which value the
transform produces one-for-one and so preserves injectivity on the element
set. The custom_name axis has a pre-existing defect of its own, independent of
this change: with the element already typed Bool, the same NOT IN returns 1
against an oracle of 2 on unmodified master.
The captured-timezone case matters in practice, since TimezoneMixin binds
DateLUT::instance() at construction while doGetName() returns the constant
"DateTime" when no timezone is explicit, so two DateTime types can differ in
the timezone the DAG observes while reporting identical names. A predicate
gated on a name difference skips exactly that pair and leaves it wrong. Both
of the narrower designs considered, widening the two equals tests and gating
on getName(), are pinned as mutants by the new test, as is dropping the
DateTime restriction.
The function is static with two call sites, both in this file, so there is no
Replicated or Shared sibling copy to keep in step, and skip indexes inherit
the fix through the same KeyCondition. The scalar, literal-IN and range paths
do not route through it and were measured unaffected.
The new test asserts wrong results against a Memory-engine oracle rather than
a pruning delta, since a pruning-delta oracle would pass on a conservative
regression. It covers four key transforms, partition key and primary key,
DateTime64, both directions of the asymmetry, the both-explicit shape, the
same-name captured-timezone shape and has(), against controls that read
correct before the fix. Three further carriers cover the Nullable wrapper,
over IN, has() and DateTime64; they need transform_null_in = 1, because at its
default of false the same queries read correct even before the fix, and
allow_nullable_key = 1, which is a MergeTree setting and so goes in the DDL
rather than a query-level SET. Their own two controls read correct before the
fix, the second of them by turning transform_null_in back off, which is what
shows that co-factor is real rather than decoration. Two of the timezone
controls assert NOT IN and != on that axis, which the restriction above leaves
correct in both arms, and one asserts the Bool negative predicate that pins
the restriction itself.
Because those rows assert answers, they also pass if the transform is declined
rather than corrected, so one further row asserts SelectedParts on a
two-partition table to pin that pruning is still used. Its two hours are
interleaved across two days so the element's instant lies inside the ts range
of both parts, which stops the min-max index standing in for the partition
index. The leading SET session_timezone is load-bearing: the runner randomizes
that setting and one of its draws is the local zone, which would make the
session zone equal the key zone and collapse the discriminator; a query-level
SET beats the runner's client argv injection, and carrier 5's
index_granularity is pinned in its DDL for the same reason. The has() carrier
disables optimize_rewrite_has_to_in, because at its default that pass rewrites
the predicate to a literal IN which never reaches the changed helper.
That SelectedParts row reads ProfileEvents from the initiator's query_log, so
the test is tagged no-parallel-replicas and pins enable_parallel_replicas and
automatic_parallel_replicas_mode off immediately before it. SelectedParts is
counted where each read executes, so with parallel replicas the value stops
being a function of whether the partition index ran on the initiator: measured
on a local server with a parallel_replicas cluster, forcing parallel replicas
on with parallel_replicas_local_plan = 0 collapses the row to 0 for both a
pruned and an unpruned read while the answer stays correct, and the pin
restores it to 1. The tag is what the CI flavour that enables parallel
replicas in the default profile honours, since that is server-side and a
query-level pin cannot be what opts the test out of it; the pin covers any
other path that reaches the test with them enabled. Neither that tag nor the
pin suppresses settings randomization, and no no-random-settings or
no-random-merge-tree-settings tag is needed.
…g wrappers
The previous shape of this fix tested `isDateTimeOrDateTime64(removeNullable(input_type))`,
so it recognized a timezone only at depth 0 and 1. `DataTypeArray::equals`,
`DataTypeMap::equals`, `DataTypeTuple::equals` and `DataTypeLowCardinality::equals` all
delegate to their children, so a `DateTime` timezone is exactly as invisible to `equals`
one or more wrappers down, while a higher-order function takes its lambda argument type
from the runtime wrapper type (`FunctionArrayMapped` builds each argument from
`array_type->getNestedType()`). An `Array(DateTime('UTC'))` key read with an
`Array(DateTime)` set element therefore still transformed under the session timezone and
named a partition the row does not live in: silent wrong results, the same class the
changelog entry already promises to fix.
Rather than adding one wrapper per round, the type test is now a small structural helper
that rebuilds the element type with every `DateTime`/`DateTime64` leaf replaced by the
corresponding leaf of the DAG's type, refusing (and changing nothing) if any other leaf
differs. Ten measured carriers close: `Array`, `Map` via `mapApply`, `Array(DateTime64)`,
`Array(Nullable)`, `Map(String, Nullable)`, `Array(Tuple)`, `Array(Array)`,
`Array(LowCardinality)` through the constant-equality caller, and both
`SimpleAggregateFunction` shapes.
Two design points, both settled by measurement rather than preference.
The obvious remedy -- adopting the pair wholesale when `equals` is true -- is unsound:
`DataTypeNumber<UInt8>::equals` is a bare `typeid` test and `Bool` is `UInt8` plus a
`DataTypeCustomFixedName`, so `Array(Bool)->equals(Array(UInt8))` is true and a wholesale
relabel would swap a `Bool` label onto a bare `UInt8` leaf inside the wrapper, collapsing
the transform's value map. The helper is therefore leaf-selective: only a `DateTime` or
`DateTime64` leaf is ever replaced, and a non-DateTime leaf is returned unchanged. There
is additionally a per-level custom-name refusal, in the spirit of
`DataTypeVariant::equals` ("The same data types with different custom names considered
different. For example, UInt8 and Bool."). Measured, those two guards are redundant for
`Bool`: each alone keeps the negation control green.
The leaf test runs BEFORE the custom-name refusal, and that order is load-bearing rather
than incidental. `SimpleAggregateFunction` is a custom name whose storage type is its
argument type verbatim, so a `SimpleAggregateFunction(max, DateTime('UTC'))` key carries a
genuine `DateTime` leaf under a differing name. With the refusal first, that key regressed
to the pre-fix behaviour; with the leaf test first it is fixed, along with the
`Array(SimpleAggregateFunction(...))` shape no previous round handled.
The relabel still fires only where `!input_type->equals(*dag.input_type)` was already
false, so it changes no branch decision in either direction, and it remains a relabel
rather than a conversion: `equals`-equal implies `canBeSafelyCast` (`DataTypes/Utils.cpp`)
and `castColumn` returns the argument column untouched for an `equals`-equal target
(`Interpreters/castColumn.cpp`).
`Variant` and `Object`/`JSON` are deliberately absent from the recursion. Both were
measured: an `IN` against a differently-parameterized `Variant` fails with
`CANNOT_CONVERT_TYPE` before any pruning, and `IN` over a `JSON` column is
`ILLEGAL_TYPE_OF_ARGUMENT` even for the identical type, so neither can reach the helper.
The regression test grows from 14 to 24 carriers and from 13 to 21 controls, deleting
none. Ten mutants pin the shape: reverting the relabel or inverting its direction reddens
all 24 carriers plus the pruning-count row; restoring the previous predicate reddens the
nine wrapper carriers alone; dropping both `Bool` guards together reddens the negation
control alone; and declining the pair instead of relabelling reddens only the
pruning-used row, which is what keeps the rejected alternative distinguishable.
`adoptDateTimeLeafTimezones` returns nullptr when a leaf other than
`DateTime`/`DateTime64` differs between the set element's type and the type the
transform DAG was built against, meaning the pair is not interchangeable. The
call site discarded that answer and continued with the element's own type, which
is the behaviour the normalization exists to remove: the DAG then runs under the
element's timezone and the partition index prunes a part that does hold matching
rows.
`equals` is blind to a custom name inside a wrapper, so this is reachable from
ordinary SQL. `DataTypeNumber<T>::equals` is a bare `typeid` test and `Bool` is
`UInt8` plus a `DataTypeCustomFixedName`, so `Array(Tuple(DateTime('UTC'), Bool))`
and `Array(Tuple(DateTime, UInt8))` are equals-equal while the `Bool` leaf refuses
relabelling. A bare `Bool` key reaches it the same way.
Make a refusal decline the transformation instead. `applyDeterministicDagToColumn`
already documents itself as conservative, returning false when the transformation
cannot be proven safe, and both callers handle that by declining the atom, so
every part is scanned and the answer stays correct. Measured on the pristine
master snapshot, on the pre-recursion binary and on the reverted-relabel binary,
the affected reads are wrong on all three, so this repairs a pre-existing wrong
result rather than one introduced with the recursion.
Adds three carriers for the refusal (one wrapped, two bare) with two controls,
and a wrapper-shaped pruning-USE oracle. The existing pruning oracle is built on
a bare `DateTime` key, so it pins no recursive branch; every wrapper row asserts
only `count()`, which a declined transform also satisfies via a full scan. The new
oracle reads `SelectedParts` for an `Array(DateTime('UTC'))` key over two parts
whose min-max ranges both contain the element, so a decline moves it from 1 to 2.
Internal second-model review (click to expand)An independent model reviewed this diff cold against the ClickHouse review checklist, and its
This is not introduced here, and the reasoning is worth stating because it also bounds the change.
💡 Two comment characters. Lines 405-406 of the test write A request to add a Fixed during review: the PR body's carrier, control and mutant counts and its shipping Build ID were Session id: cron:clickhouse-review-slot-10:20260807-082400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-10:20260807-082400 |
|
cc @hanfei1991 @Avogar, could you review this? The key transform DAG reads a timezone off the type it is handed, but |
|
Workflow [PR], commit [0940a01] Summary: ✅
AI ReviewSummaryNo actionable correctness, safety, or performance issues remain on the current head. The PR fixes the Missing context / blind spots
Final Verdict
LLVM Coverage ReportMeasured on commit 0940a01.
Changed lines: Changed C/C++ lines covered: 69/111 (62.16%) · Uncovered code |
CI finish ledger - d21b532Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Neither failure is PR-caused: this PR touches only Session id: cron:our-pr-ci-monitor:20260807-143000 |
|
Fixing PR for the |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes5 object files changed (+19.50 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units12 translation units recompiled, 41 s compile time in total, 12 of them have a recent master baseline. |
CI finish ledger -
|
| Check / test | Reason | Owner / fixing PR |
|---|---|---|
Stress test (amd_msan) / Logical error: Not-ready Set is passed as the second argument for function 'globalIn' (STID 0250-41a5), Failures: 1/5 |
not PR-caused, trunk defect on the object-storage path pre-filter. The abort frames are StorageObjectStorageSource::createFileIterator (src/Storages/ObjectStorage/StorageObjectStorageSource.cpp:581) into VirtualColumnUtils::filterByPathOrFile (src/Storages/VirtualColumnUtils.h:136) into getFilterByPathAndFileIndexes (src/Storages/VirtualColumnUtils.cpp:419) into filterBlockWithExpression (:163) into FunctionIn::executeImpl (src/Functions/in.cpp:128), reached from ReadFromObjectStorageStep::initializePipeline under an AST fuzzer query. The diff here is src/Storages/MergeTree/KeyCondition.cpp plus one stateless test, and key analysis is not on that call path. |
#112968 (external, open) |
That PR is the remedy for this exact call site rather than a same-area coincidence: it rewrites
StorageObjectStorageSource::createFileIterator and VirtualColumnUtils.{cpp,h}, the two frames
above the aborting function, and its regression tests are named
04669_object_storage_path_filter_global_in and 04907_file_url_path_filter_global_in.
No other check failed at this head, and Config Workflow, Style check and Finish Workflow are
all success with 0 nodes DROPPED.
Session id: cron:our-pr-ci-monitor:20260831-083000
…wCardinality wrapper
The adopt added earlier in this PR is gated on `input_type->equals(*dag.input_type)`. A bare
comparison constant is never `Nullable`, so on a `Nullable(DateTime(tz))` key column the pair is
`DateTime('UTC')` vs `Nullable(DateTime(tz))`, `DataTypeNullable::equals` is false, and the adopt
never runs. `LowCardinality` behaves the same way, and so does a wrapper that differs one level
down, as in `Array(Nullable(DateTime))` against an `Array(DateTime)` element.
Only one of the two unequal-type routes was actually wrong. The general route casts the constant to
`dag.input_type` and that round trip already moves it onto the key column's zone, which is why
`toString`, `toHour` and `cityHash64` keys were correct. `try_apply_direct_cast_fast_path` exists to
skip that round trip, so it cast the constant straight to the CAST's result type and rendered it in
the constant's own zone, naming a mark or partition the row does not live in. Measured on a
`Nullable(DateTime('America/New_York'))` key with a `DateTime('UTC')` constant, the condition read
`CAST(d, 'String') in ['2024-11-03 05:30:00', ...]` while the stored key was `01:30:00`, and the
matching row was dropped with no error.
`adoptDateTimeLeafTimezones` now looks through a wrapper only the key column carries, at any depth,
and no longer relies on an `equals` precondition: every leaf checks the kinds it is about to
combine. The returned type always keeps the element's own structure, so it still describes the
column it is attached to and only timezones move. The call site stays additive: an adopt that
refuses on an `equals` pair declines the atom exactly as before, and one that refuses on an unequal
pair leaves the existing casts to reconcile it, so no atom is newly declined and no pruning is lost.
The DateTime leaf test deliberately stays ahead of the custom-name refusal. With the order reversed,
`SimpleAggregateFunction(anyLast, DateTime(tz))` key columns hit the refusal because their
`getName()` embeds the zone, which silently gave up the pruning the earlier commits had won.
Closes: ClickHouse#117766
Six new carriers in 04770 cover a `Nullable` key with `=` and with `IN`, `PARTITION BY`,
`DateTime64`, a `LowCardinality` key, and the wrapper mismatch inside an `Array`; all six return 0
before this commit and 1 after. The `LowCardinality` carrier uses `IN` because a scalar comparison
resolves a common supertype for its arguments and retypes the constant before key analysis runs, so
the `=` form reads 1 either way and would witness nothing. Controls pin that the zeros were dropped
rows rather than an empty fixture, that an absent instant still reads 0, and that the index still
prunes rather than the atom being declined.
…uning test The carrier block added for key-only wrappers reused the numbers 23-24 and sat between blocks 12-14 and 15-22, so the numbering no longer read in file order. Renumber it 15-20 and shift the two blocks after it. Two comments no longer described the code. The custom-name ordering note claimed the reverse order "silently reintroduces the bug"; since an adopt refusal on an `equals` pair declines the transform, the reverse order returns the right count and loses the pruning instead, which is what the note now says. And two references to `count` as a value carried call parentheses, which the repository convention reserves for applying a function.
Relabelling rebuilt every composite it walked, so a key column typed as a custom name over a composite came back as the plain composite: `Point` became `Tuple(Float64, Float64)`. `wkb` picks its implementation from the runtime type name, so it threw on the rebuilt type, key analysis turned that into a refusal, and the table silently stopped pruning. Measured on a 16-granule `Point` key, `ORDER BY wkb(p)`: master reads `Granules: 2/16` with a real condition, this branch read `Condition: true` over `16/16`. The rows returned were correct throughout, which is why only a plan assertion catches it. Each composite branch now returns the element type untouched unless a leaf actually moved, detected by comparing the recursed child against the original. Nothing else in the walk changes. The `DateTime` leaf keeps adopting unconditionally, and deliberately does not skip when the two type names match: a `DateTime` binds the session zone at construction and reports the bare name `DateTime` either way, so two types with the same name can still carry different zones. Skipping on equal names was tried and it silently un-fixed the existing `partition_same_name` carrier, which exists for exactly that case.
The note grew to four lines and carried why a stripped type name matters at runtime, which belongs in the commit that made the change rather than at the call site. Keep the two invariants a reader needs here: a timezone under a wrapper is as invisible to `equals` as a bare one, and rebuilding a composite would drop its customizations.
|
Rescoped this round, so title, changelog entry and description are updated: the fix now also covers a wrapper carried by the key column alone, which is the shape reported in issue 117766, and One neighbouring shape is deliberately left alone, because it is pre-existing and sits on a different axis (representation, not timezone): a |
|
Splitting the scale axis out of this PR turned up a second defect in The invariant is that a constant handed to a deterministic key transform has to be a value
Case 1 is fixable: prefer the route through Case 2 is not fixable at that layer. So: fix case 1 and leave case 2, or fix both and give up that pruning? I lean towards the |
`adoptDateTimeLeafTimezones` refused every pair whose custom names differ, so a
key column of type `SimpleAggregateFunction(anyLast, Array(DateTime('UTC')))`
against an element typed `Array(DateTime)` fell into the caller's
`equals`-refusal branch and the atom was declined. Correctness was preserved by
reading every part, which is the pruning the rest of this change exists to keep:
`PARTITION BY arraySum(arrayMap(x -> toYYYYMM(x), a))` on that key answered
`Condition: true` over all parts where master built the real key condition.
A custom name is representation-neutral, so an `equals`-equal pair is
interchangeable and `dag_type` is the exact type to hand the transform: it
carries the timezones, the custom name and the tuple element names that `equals`
ignores, none of which the rebuild below can reproduce. The refusal still stands
on a leaf, where a custom name can change what the transform computes -
relabelling a `UInt8` element to `Bool` would render every nonzero value as
`true` and collapse the value map an exact `NOT IN` relies on.
Measured on three binaries with the new test rows. Pristine master answers 0
rows for the carrier (wrong results) and prunes; the previously published head
answers 1 row and stops pruning; this change answers 1 row and prunes.
`control_bool_negation`, which pins the leaf refusal, reads 2 on all three.
No result-level change across 355 tests of the geometry, `Nested`,
`SimpleAggregateFunction`, `Bool`, key-condition and partition-pruning families,
run on both arms.
CI finish ledger - 5c00e7aEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260910-053056 |
… pick up the Iceberg partition-pruning revert (ClickHouse#119298)
CI finish ledger - 79694fbEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The revert merged at 2026-09-10T17:26:35Z, 55 minutes after the master merge this run was built Session id: cron:our-pr-ci-monitor:20260912-123103 |
…dition-dag-timezone-attribute
…bcolumn_shared_offsets_continuation` on master Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…refusal The AI review asked for a `Bool` carrier on the direct-`CAST` path, where the transform DAG is a bare `CAST` on the input rather than a function call. The existing bare-`Bool` carrier goes through `PARTITION BY toString(b)`, so `try_apply_direct_cast_fast_path` was not exercised by the test. A key of `b::String` reaches that fast path, and the new carrier pins that the leaf refusal in `adoptDateTimeLeafTimezones` is evaluated before it: `b = 1::UInt8` and `b IN (1::UInt8)` both return the oracle's 8 rows instead of the 0 rows master returns, while an element that carries the key's own name (`b = true`) still prunes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The carrier added in cc6f73a printed the oracle's 8 rows on master as well, so it pinned nothing. Two independent reasons, both measured against master 01b8f1c and this head: - `SELECT count() FROM k_bool_cast WHERE b = 1::UInt8` is answered by the trivial-count-with-sparsity path (`ReadFromPreparedSource`), which never runs key analysis. Reading the rows instead, through the subquery wrapper the other 79 rows of this test use, returns 0 on master against an oracle of 8, with `Condition: (CAST(b, 'String') in ['1', '1'])` and `Granules: 0/16`. - A one-element literal `IN (1::UInt8)` list is coerced to the key's own type before the transform sees the element, so it builds `CAST(b, 'String') in 1-element set` and prunes to 9/16 correctly on both arms. `IN (SELECT 1::UInt8)`, the form the sibling `partition_bool_in` row already uses, reaches the refusal and returns 0 on master. Both key rows now flip 8 -> 0 on master and stay at the oracle's 8 here. The two exact-name controls move to the same reading shape, and one plan row is added for the property their comment claims: a count cannot distinguish "the atom still prunes" from "the atom was blanket-declined", while `Granules: 9/16` can. The two fixtures are also added to the test's DROP lists, which every other fixture is in. Co-Authored-By: Claude Opus 5 <[email protected]>
… check `Upgrade check (amd_release)` intermittently fails its `Error message in clickhouse-server.log` sub-test on one benign line: <Error> StorageFileLog (test_1.filelog_bad_path_attach): The absolute data path should be inside `user_files_path`(/var/lib/clickhouse/user_files/) 04202_filelog_attach_path_outside_user_files has an explicit ATTACH query for a FileLog table whose path is outside `user_files_path`. ATTACH is LoadingStrictnessLevel::ATTACH, which is >= SECONDARY_CREATE, so the constructor takes the relaxed branch in src/Storages/FileLog/StorageFileLog.cpp: it logs at <Error> and returns instead of throwing BAD_ARGUMENTS. That branch is what the test covers, since refusing to load at reattach time would break server startup. The table outlives the test because stress threads run with a fixed --database=test_N (ci/jobs/scripts/stress/stress.py) and clickhouse-test skips its per-test teardown whenever --database is set, so the shared database is never dropped. The upgrade restart re-attaches the table, the relaxed branch fires again, and the line lands in the scanned log, where the post-restart scrub had no entry for it. The matcher keys on the StorageFileLog logger plus the message and carries no table or database name, so the same message is allowlisted for any FileLog table. The `): ` boundary keeps the discriminating cases visible: a different message from the same logger, this message from another storage, and a Code: 36 throw of the same text (the strict-mode path, a real failure) all still fail the job. Validated against the failing run's own 12.6 MB clickhouse-server.upgrade.log (PR ClickHouse#117355, sha cff5510): with the entry the scan artifact is empty, and with it removed the artifact is the 189-byte line CI reported as the failure. Related: ClickHouse#113781 Co-Authored-By: Claude Opus 5 <[email protected]>
It creates and drops dozens of tables, so under the flaky check with `meta in keeper` and `s3 storage` it runs over the 180 s limit (`Test runs too long (> 180s)`) and fails the `CH Inc sync` check. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…analysis
`DataTypeTuple::equals` ignores `hasExplicitNames` (an anonymous tuple compares
by its ordinal names), while `SerializationTuple::serializeTextJSON` writes a
named tuple as an object and an anonymous one as an array. So with a key like
`PARTITION BY toJSONString(a)` over `Array(Tuple(`1` DateTime('UTC')))`, a set
element `Array(Tuple(DateTime))` passed `equals`, was run through the key
transform under its own naming mode, and the matching part was pruned away.
`replaceNestedTypesInPair` now refuses such a pair, so an `equals`-equal pair
makes `convertColumnForDeterministicDag` decline the atom instead of mispruning.
This is only ever more conservative than before. New test `05257` covers both
mode directions with and without a timezone difference (0 rows without the
fix, the oracle's 1 with it) and proves same-mode pairs still prune.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
CI finish ledger - b71bf72Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens.
This PR's diff is Session id: cron:our-pr-ci-monitor:20260925-133210 |
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=113781&sha=b71bf72071825a7f13b0f8bcf31d4a7c1c370849&name_0=PR&name_1=AST%20fuzzer%20%28amd_release%2C%20oracle%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.
I merged the latest |
|
The fix is already in progress: #113332 (open), which fixes #106922. The empty needle is incidental.
CREATE TABLE tab (id UInt64, val LowCardinality(Nullable(String)), INDEX idx (val) TYPE text(tokenizer = 'asciiCJK', preprocessor = lower(val))) ENGINE = MergeTree ORDER BY id;
INSERT INTO tab SELECT number, if(number % 3 = 0, NULL, 'foo bar') FROM numbers(30);
SELECT (SELECT count() FROM tab WHERE hasAnyTokens(val, '')), (SELECT count() FROM tab WHERE NOT hasAnyTokens(val, '')),
(SELECT count() FROM tab WHERE isNull(hasAnyTokens(val, ''))), (SELECT count() FROM tab WHERE NOT hasAnyTokens(val, 'foo'));
The CI table shape ( |
alexey-milovidov
left a comment
There was a problem hiding this comment.
Ok, a little bit complicated though.
Closes: #117766
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix rows silently dropped by primary key and partition pruning when a
MergeTreekey expression applies a timezone-observing function such astoYYYYMM,toStringor aCASTtoStringto aDateTime/DateTime64column and a compared constant declares a different timezone. Both a scalar comparison constant and anIN-set element are affected, including when the differing timezone sits under anArray,Map,Tuple,Nullable,LowCardinalityorVariantwrapper that only one side carries, when a custom type name such asSimpleAggregateFunctionwraps that composite on one side only, and when a sibling leaf differs only by a custom type name (BoolagainstUInt8). Also fix the same loss when a comparedTupleand the key column's disagree on explicit element names, whichtoJSONStringrenders as an object against an array; no timezone difference is needed.Description
Root cause.
applyDeterministicDagToColumnnormalizes the constant to the type the key transform DAG was built against, but only when the two are notequals-equal.DataTypeDateTime::equalsignores the timezone, so the transform reads its zone off the constant and names a mark or partition the row does not live in.The change. Rebuild the constant's type with every
DateTime/DateTime64leaf replaced by the corresponding leaf of the key column's type, looking through the wrappers named above on either side. That structural walk lives besidecallOnNestedSimpleTypesasreplaceNestedTypesInPair, so this file keeps only the leaf policy;Variantis covered by the walk rather than by a seventh branch here. The result keeps the constant's structure, so this relabels rather than converts. A custom name over a composite only renames it, so such a pair is relabeled whole once the recursion has cleared its children; on a leaf the name can change the value map (Boolrenders every nonzeroUInt8astrue), so it is refused and the atom is declined as before.Validation.
05240compares 116 rows against aMemory-engine oracle, including rows that pin the key as still USED (Granules: 1/2) rather than declined, and that aVariantholding twoequals-equal alternatives is refused rather than relabelled.05257covers the naming-mode class: its three mismatch rows read 0 on 26.3, 26.8 and master against an oracle of 1, and 1 here, while the same-mode controls still prune (Parts: 1/2).Affected: 26.3, 26.6, 26.7 and 26.8 all contain both
c4ebb3c7320e64fanda0a00157398d840.v26.3-must-backportappreciated.Four-arm matrix for the wrapper carrier
session_timezone = 'Asia/Kolkata', keySimpleAggregateFunction(anyLast, Array(DateTime('UTC'))),PARTITION BY arraySum(arrayMap(x -> toYYYYMM(x), a)), element[toDateTime(1675195200)]; theBoolrows use key
SimpleAggregateFunction(anyLast, Array(Bool))withPARTITION BY toString(a)and anelement
[2], whose oracle is 2:NOT INrows returned (want 2)!=rows returned (want 2)A neighbouring shape is deliberately left alone: a
DateTime64scale mismatch under a wrapper the keycolumn alone carries still takes the direct-
CASTfast path. Measured identical on pristine master andon every arm above, so it is pre-existing and a separate axis from the timezone one.
Workflow [PR]
Sync PR [sync-upstream/pr/113781]
Version info
26.10.1.1468-master(included in26.10and later)