Repository navigation
Send the update_field bound of the ClickHouse dictionary source as a Unix timestamp for non-text columns - #127765
Conversation
…Unix timestamp
ClickHouseDictionarySource::getUpdateFieldAndDate formatted the lower bound of
an incremental update (previous update time - update_lag) as wall-clock text in
the server's default time zone, and the receiving server parses
`update_field >= '<text>'` in the column's time zone. So:
- when the column's zone differs from the server's (DateTime('UTC') on a
non-UTC server, a remote server in another zone), the bound is shifted by the
difference all the time; east of the column's zone it lies in the future and
rows inserted after the first load are never loaded (measured on 26.8.28.14
and 26.9.19.9 with TZ=Europe/Amsterdam);
- in the hour repeated at the end of DST the text is ambiguous and resolves to
the first occurrence, so during the second pass every update re-reads the
last hour. CI servers run in Europe/Amsterdam; on 2026-10-25 01:00-02:00 UTC
02530_dictionaries_update_field_{hashed,complex_key_hashed} re-read 'Second'
together with 'SecondUpdated' on every update, and a hashed layout keeps the
first fetched row of a key, so the tests timed out ('flat' keeps the last
row and passed).
A decimal Unix timestamp is read by the DateTime/DateTime64 text parsers as
the same instant in every zone and every date_time_input_format. Integer
update fields now work too; Date/Date32 still fail; a String update_field now
matches every row on each update. Sources that send the text to an external
system (MySQL, PostgreSQL, ODBC, HTTP, executable) are unchanged: there the
external system defines how the text is read.
The new test sets update_lag so that the bound falls in the repeated
Europe/Amsterdam hour on a DateTime('Europe/Amsterdam') column; it fails on
master with the server in Europe/Amsterdam, UTC and Asia/Tokyo.
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 findings; bounded: 1 full pass + 1 fix round + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261025-041300 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261025-030700 |
|
cc @nihalzp @vitlibar, could you review this and add the |
|
Workflow [PR], commit [7c73d1c] Summary: ✅
AI ReviewSummaryThis PR fixes time-zone-dependent incremental dictionary updates by sending a padded Unix timestamp for non-text Final Verdict✅ Approve. |
CI finish ledger - 47739a3Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
CIDB has no other Session id: cron:our-pr-ci-monitor:20261025-133007 |
|
🕵️ @groeneai The fix looks right for every time-typed column. I checked on master that A With a A
Minor: |
|
@groeneai are you also sure this is portable to other OS, c++ compilers and is it safe for timezones and locales? |
A bound below 0 (update_lag larger than the current time) was sent as `'-100'`, which no DateTime type accepts, so every update failed. A bound with fewer than 9 digits (before 1973) is rejected, or read as `YYYYMMDD` by the DateTime parser: `'20000101'` matched 2000-01-01 and skipped rows from 1970. A 10-digit number is read as a Unix timestamp by every DateTime type and every `date_time_input_format`, and integer columns ignore the leading zeros. The test gains an 8-digit bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units22 translation units recompiled, 178 s compile time in total, 22 of them have a recent master baseline. |
|
Thanks. Both points are in e36e37a.
Portability, time zones, locales:
|
|
@groeneai On second thought, the A constant that picks its form from the column type keeps the old text comparison for text columns and the Unix timestamp for everything else: update_field >= if(toTypeName(update_field) LIKE '%String%', '<old local text>', '<10-digit timestamp>')On master with the server in |
…tamp A `String` update_field holding 'YYYY-MM-DD hh:mm:ss' text sorted every row above the 10-digit timestamp bound, so each incremental update re-read the whole source. With several source rows per key, a `hashed` dictionary keeps the first fetched row of a key, so it could go back to an older value on every update. The ClickHouse source now sends `update_field >= if(toTypeName(update_field) LIKE '%String%', '<local text>', '<timestamp>')`. The `if` folds to a constant on the receiving server, so the primary key is still used, and the form works with both analyzers (measured on 26.3, 26.8 and 26.10). The other sources keep sending the quoted local text. The test gains a `String` update_field; it fails without this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
update_field bound of the ClickHouse dictionary source as a Unix timestampupdate_field bound of the ClickHouse dictionary source as a Unix timestamp for non-text columns
|
Done in f737654.
|
`toTypeName` of a `Dynamic` column is `Dynamic`, so it got the 10-digit timestamp bound, while the comparison dispatches on the contained values: a `Dynamic` holding 'YYYY-MM-DD hh:mm:ss' text compared every row above the bound as text, so each update re-read the whole source, the same rollback the `String` case had. A `Dynamic` column is now compared with the local text, as before this PR. A per-row choice is not possible with a constant bound: a `Dynamic` holding `DateTime` rejects a non-constant `String` right-hand side (`NO_COMMON_TYPE`). A `Variant` with a `String` variant already matched `%String%`. Measured in Europe/Amsterdam with the bound in the repeated DST hour on 26.3, 26.8 and 26.10, both analyzers: the exact rows for every ordinary type and for `Dynamic` text, and the same granules read for a `DateTime64` and a `String` primary key. The test gains a `Dynamic` update_field (the source table moves from `TinyLog`, which rejects `Dynamic`, to `Memory`); it fails without this change. The 8-digit bound is checked for the timestamp form only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`toTypeName` of `SimpleAggregateFunction(anyLast, Dynamic)` does not start with `Dynamic`, so a column of that type holding 'YYYY-MM-DD hh:mm:ss' text got the 10-digit timestamp bound and every update re-read the whole source, the rollback the `Dynamic` case had. The guard now matches `Dynamic` anywhere in the type name. Census in Europe/Amsterdam with the bound in the repeated DST hour, 33 column types (`String`/`FixedString`/`Dynamic` under `Nullable`, `LowCardinality`, `Variant`, `SimpleAggregateFunction`, JSON paths, and the time and numeric types, including `SimpleAggregateFunction` over them), on 26.3, 26.8 and this build: only the three `SimpleAggregateFunction(..., Dynamic)` shapes differed from the released text bound before this change, and every type now selects the exact rows. A `DateTime64` and a `String` primary key still read 41/64 and 40/64 granules with both analyzers. The test gains a `SimpleAggregateFunction(anyLast, Dynamic)` update_field; it fails without this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@groeneai This test takes 45 seconds -> https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129052&sha=latest&name_0=PR&name_1=Fast+test+%28arm_darwin%29 It should be faster and if it's not possible it should be removed from fast test |
|
Acknowledged. The time goes into ten sequential waits for an incremental dictionary update: the external loader checks for outdated dictionaries every 5 s ( |
|
Fixed in #129298: the ten cases now share one round of dictionary updates, so the test takes about 5 s instead of about 49 s (debug build, median of 20 runs, max 5.3 s) with the same output, and it stays in the fast test. |
Related: #98708
Related: #125510
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed incremental updates (
update_field) of dictionaries with aClickHousesource. The lower bound was sent as the server's local time, so it was shifted when the column's time zone differed from the server's (for example, with aDateTime('UTC')column on a server east of UTC, new rows were never loaded), and in the hour repeated at the end of DST every update re-read the last hour of rows. The bound is now sent as a Unix timestamp for non-text columns.Description
02530_dictionaries_update_field_hashedand_complex_key_hashedhit the 600 s deadline waiting forSecondUpdatedin jobs started on 2026-10-25 00:05-01:40 UTC, for example this job of #98708.On 26.8.28.14, a dictionary with
SOURCE(CLICKHOUSE(... UPDATE_FIELD 't'))over aDateTime('UTC')column on a server withTZ=Europe/Amsterdamnever loads rows inserted after the first load.getUpdateFieldAndDateformattedprevious update time - update_lagas wall-clock text in the server's time zone, and the receiving server parsesupdate_field >= '<text>'in the column's time zone. In the repeated hour the text is ambiguous and resolves to the first occurrence, so CI servers (Europe/Amsterdam) re-readSecondtogether withSecondUpdatedon every update, andhashedlayouts keep the first fetched row of a key (flatkeeps the last one and passed).The bound is now
if(toTypeName(update_field) LIKE '%String%' OR toTypeName(update_field) LIKE '%Dynamic%', '<local text>', '<Unix timestamp>'), so a column that can hold text is still compared as text. Other types get the timestamp, clamped at 0 and padded to 10 digits (a shorter number is rejected or read asYYYYMMDD), whichDateTime/DateTime64parse as the same instant in any time zone anddate_time_input_format. Theiffolds to a constant, so the primary key is still used, with both analyzers (checked on 26.3, 26.8, 26.10).Datefails as before. Other sources keep the text.The new test puts the bound with
update_lagin the repeated hour, failing on master with the server inEurope/Amsterdam,UTCandAsia/Tokyo, and at an 8-digit timestamp, failing without the padding.String,DynamicandSimpleAggregateFunction(anyLast, Dynamic)arms fail when text is compared with the timestamp. It passes 20 times with random settings.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127765]
Version info
26.11.1.1127-master(included in26.11and later)