Repository navigation
Enable date time input format "best effort" by default - #89334
Merged
alexey-milovidov merged 54 commits intoMay 13, 2026
Merged
Conversation
Contributor
|
Workflow [PR], commit [931229e] Summary: ✅ AI ReviewSummaryThis PR changes the defaults of Final VerdictStatus: ✅ Approve |
Member
|
Shouldn't we mark it as backward-incompatible so users will notice it in the changelog? I believe it will break lots of user queries |
Member
Author
|
Yes, let's mark it, just for attention. |
…mat_best_effort-by-default
…mode` default change to `best_effort` Pin existing tests to `date_time_input_format='basic'` where they rely on basic parsing behavior but test unrelated functionality (nullable conversions, CSV parsing, DateTime64 edge cases, timezone conversions, etc.). Update schema inference cache reference files to reflect the new default `BestEffort` value. Move settings changes history entries from version 25.11 to 26.4 so the `02995_new_settings_history` validation test passes. Add new test `04070_date_time_best_effort_default` that validates the new default `best_effort` parsing works without explicit SETTINGS, and that `basic` mode still rejects non-basic formats when explicitly requested. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…mat_best_effort-by-default
`toDateTime`, `toDateTime64`, and `CAST ... AS DateTime[64]` use `cast_string_to_date_time_mode`, not `date_time_input_format`, so the earlier `SET date_time_input_format = 'basic'` adjustments did not restore the strict-parsing behavior these tests rely on. Also fix a typo in `04070_date_time_best_effort_default.sql` where the wrong setting name was used to exercise the basic-mode rejection path. CI report: #89334 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…mat_best_effort-by-default
…mat_best_effort-by-default
Extend `04070_date_time_best_effort_default` with `toDateTime64` and `CAST ... AS DateTime64` cases, both for the new default `best_effort` behavior and for basic-mode rejection. Reviewer asked the test to also cover `DateTime64`, since `cast_string_to_date_time_mode` applies to both `DateTime` and `DateTime64` conversions. CI report: #89334 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…mat_best_effort-by-default
…mat_best_effort-by-default
…mat_best_effort-by-default
…ime_mode` default change to `best_effort` Pin tests to `basic` mode where they rely on strict parsing semantics that are unrelated to the feature being tested: - `00664_cast_from_string_to_nullable`: pin both `date_time_input_format` and `cast_string_to_date_time_mode`. With `best_effort`, the lone string `'2018'` parses as `2018-01-01 00:00:00` instead of `NULL`. - `01195_formats_diagnostic_info`: pin `date_time_input_format` for CSV/TSV/CustomSeparated/JSONCompactEachRow parsers so the diagnostic error messages stay anchored to the basic `YYYY-MM-DD hh:mm:ss` form. - `02118_deserialize_whole_text`: pin so `Date`/`DateTime`/`DateTime64` deserialization rejects trailing garbage strictly, as the test asserts. - `01825_json_type_nbagames`, `04062_text_index_json_all_values_ghdata`: pin so JSON path inference does not promote ISO date strings to `DateTime64`, which would change `JSONAllPathsWithTypes` / `JSONAllValues` output and the resulting `cityHash64`. CI report: #89334 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Address review feedback: `04070_date_time_best_effort_default` only exercises the function/`CAST` paths (which use `cast_string_to_date_time_mode`). Add a complementary test that verifies the new `best_effort` default for `date_time_input_format` through row input formats (`CSV`, `TSV`) using `clickhouse-local`, plus a control with `date_time_input_format='basic'` showing the old strict behavior is still reachable on demand. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…mat_best_effort-by-default
…mat_best_effort-by-default
groeneai
added a commit
to groeneai/ClickHouse
that referenced
this pull request
May 11, 2026
The original test (added in ClickHouse#104313 to cover ClickHouse#104307) drove the bug condition through `FileCache::freeSpaceRatioKeepingThreadFunc` with `keep_free_space_elements_ratio = 1.0`. That setting causes `cache->initialize()` to schedule the asynchronous background eviction task at `FileCache.cpp:444`, which then races with the test's `read_and_check` and intermediate `assertProbationary` / `assertProtected` calls. On slow builds (notably `Unit tests (amd_llvm_coverage)`) the background thread evicts entries between the populate and assert steps, causing the test to fail spuriously even though the underlying fix is correct. Confirmed master-branch failures on commits `74e1c5ed` (16:03:32 UTC, line 1626 mismatch) and `407d6cca` (16:24:46 UTC, `assertProtected` mismatch at line 214 from line 1616). The same failure pattern reproduces in PR run for ClickHouse#89334 (b5c32ee, line 214 mismatches). All failures are exclusive to the coverage shard; tsan / asan_ubsan / msan all pass. The replacement test exercises `SLRUFileCachePriority::collectEvictionInfo` directly, constructing the priority queue and adding three protected-only entries via `addForRestore(... QueueEntryType::SLRU_Protected ...)`. This reproduces the exact bug condition (probationary empty, protected populated, `is_total_space_cleanup=true`) without involving the file cache's asynchronous machinery, making it deterministic across all build flavors. Verified locally: - With the fix in `SLRUFileCachePriority::collectEvictionInfo`, the test passes 10/10 in 0 ms. - Reintroducing the original `chassert` aborts the unit test process with `Logical error: 'evict_size_from_probationary || evict_elements_from_probationary'` and exit code 134 (SIGABRT), confirming the test still catches the regression. - All 11 `FileCacheTest.*` tests still pass. CI failures observed in https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=74e1c5ed2c4437352b486d59b16ee8bd98a8b688&name_0=MasterCI&name_1=Unit%20tests%20%28amd_llvm_coverage%29 and https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=407d6ccaeb432fbd86b15dc6d341651a64f447dc&name_0=MasterCI&name_1=Unit%20tests%20%28amd_llvm_coverage%29
The Kusto-conformance reference (adapted from `baby-kusto-csharp`) relies on strict-mode parsing for `DateTime64` literals: strings like `'2015-12-14 11:15'` (missing seconds) must be rejected so that `dayofmonth(d)` returns `\N` for the unparseable row. Under the new `best_effort` default, that string parses successfully as `2015-12-14 11:15:00`, so the second row produces `14` instead of `\N`, diverging from the Kusto reference output. Pin both `date_time_input_format` and `cast_string_to_date_time_mode` to `basic` for this test, matching the precedent established for other strict-parser-dependent tests in this PR. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=89334&sha=7f86d608ab75b70c643b6e09dfbbe76e01a2a9aa&name_0=PR&name_1=Fast%20test PR: #89334 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…mat_best_effort-by-default
The 780-line `04092_kql_conformance_baby_kusto` test repeatedly times out (> 180s) in `Stateless tests (amd_asan_ubsan, flaky check)` and `Stateless tests (amd_debug, flaky check)` because the flaky check runs it 5x and per-run wall time is 190-260s. The only change to this test in this PR is pinning `date_time_input_format` and `cast_string_to_date_time_mode` to `basic` to preserve the existing Kusto-conformance reference output now that the default flips to `best_effort`. That change does not alter test logic, so 5x re-runs add no signal and bust the per-test timeout. Add the `no-flaky-check` tag, matching the precedent established for the other slow tests touched by this PR (e.g. `02940_variant_text_deserialization`, `04062_text_index_json_all_values_ghdata`). CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=89334&sha=fc0a0b188fe250ea80e6142eb809d5b877b52bae&name_0=PR PR: #89334 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…mat_best_effort-by-default
…mat_best_effort-by-default
…mat_best_effort-by-default
Contributor
LLVM Coverage Report
Changed lines: 90.91% (30/33) · Uncovered code |
alexey-milovidov
deleted the
date_time_input_format_best_effort-by-default
branch
May 13, 2026 04:10
This was referenced Jun 22, 2026
pull Bot
pushed a commit
to Haofei/ClickHouse
that referenced
this pull request
Jun 26, 2026
After the default of cast_string_to_date_time_mode and date_time_input_format was changed from basic to best_effort (PR ClickHouse#89334), parsing the canonical 'YYYY-MM-DD hh:mm:ss' representation (what toString(DateTime/DateTime64) produces) became significantly slower. The basic parser has an optimistic fixed-offset path for that layout, while the best-effort parser ran its general per-character state machine for every value. Add a fast path at the start of parseDateTimeBestEffortImpl that reads the fixed-offset fields of the 'YYYY-MM-DD' / 'YYYY-MM-DD hh:mm:ss' layout directly, then falls through to the general loop (for any fractional or timezone tail) and the shared finalization. It engages only when the token matches exactly and ends cleanly, so any other input is parsed by the existing code unchanged. Local x86 measurements on the date_time_64 performance test (max_threads=1, 10M rows): query 16 toDateTime(toString(x)) 0.74s -> 0.32s query 17 toDateTime64(toString(x), 3) 0.99s -> 0.60s which lands near the basic-parser baseline (0.24s / 0.53s). The reported regression is on ARM; the change is architecture independent. Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
After the default of cast_string_to_date_time_mode and date_time_input_format was changed from basic to best_effort (PR ClickHouse#89334), parsing the canonical 'YYYY-MM-DD hh:mm:ss' representation (what toString(DateTime/DateTime64) produces) became significantly slower. The basic parser has an optimistic fixed-offset path for that layout, while the best-effort parser ran its general per-character state machine for every value. Add a fast path at the start of parseDateTimeBestEffortImpl that reads the fixed-offset fields of the 'YYYY-MM-DD' / 'YYYY-MM-DD hh:mm:ss' layout directly, then falls through to the general loop (for any fractional or timezone tail) and the shared finalization. It engages only when the token matches exactly and ends cleanly, so any other input is parsed by the existing code unchanged. Local x86 measurements on the date_time_64 performance test (max_threads=1, 10M rows): query 16 toDateTime(toString(x)) 0.74s -> 0.32s query 17 toDateTime64(toString(x), 3) 0.99s -> 0.60s which lands near the basic-parser baseline (0.24s / 0.53s). The reported regression is on ARM; the change is architecture independent. Co-Authored-By: Claude Opus 4.8 <[email protected]>
alexey-milovidov
pushed a commit
to Libao-Yang/ClickHouse
that referenced
this pull request
Oct 2, 2026
`FunctionConvert` handles `Nullable` arguments itself and ran the conversion over every row, including the rows behind a NULL, whose nested value is the empty string. The generic String path tolerates that because under a `Nullable` result it parses in NULL-on-error mode, but the `DateTime64` and `Time64` branches parse in throwing mode. With `cast_string_to_date_time_mode = 'basic'` an empty string parses to 0, which hid the problem; since ClickHouse#89334 made `best_effort` the default (26.6), `toDateTime64(s, 3)` over a `Nullable(String)` column with a NULL row throws `CANNOT_PARSE_DATETIME`. `toTime64` throws on the empty string in every mode, so it failed the same way before that. For String and FixedString conversions to `DateTime64` and `Time64`, filter the NULL rows out before parsing and expand the result back, the same short-circuit the default implementation for NULLs applies to functions that cannot be executed on default arguments (`IFunction.h`). A non-NULL value that cannot be parsed still throws. Columns without NULL rows keep the old path. Related: ClickHouse#108176 Related: ClickHouse#108310 Co-Authored-By: Claude Opus 5.5 <[email protected]>
7 tasks
Merged
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Changed defaults of
date_time_input_formatandcast_string_to_date_time_modefrombasictobest_effort. Queries that previously failed to parse non-basic datetime strings (e.g.2024 April 4,Apr 15, 2020 10:30:00) may now succeed by default. To keep the old strict parsing behavior, set these settings tobasic(or usecompatibility).Version info
26.5.1.591