Skip to content

Fix best effort DT parsing on NULL strings - #108310

Merged
yariks5s merged 1 commit into
masterfrom
yarik/parse-dateTimeBestEffort-nullable
Jun 23, 2026
Merged

yariks5s merged 1 commit into
masterfrom
yarik/parse-dateTimeBestEffort-nullable

Conversation

@yariks5s

@yariks5s yariks5s commented Jun 23, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixes parseDateTimeBestEffort with timezone throwing CANNOT_PARSE_DATETIME on NULL rows of toString(Nullable(DateTime64)). Closes #108176

Version info

  • Merged into: 26.6.1.1185

@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1ed4ce0]

Summary: ✅


AI Review

Summary

This PR restores parseable nested string data for null-masked DateTime/DateTime64 toString rows, so downstream parseDateTimeBestEffort calls with an explicit timezone no longer parse an empty nested string before null propagation. The change is narrowly scoped and preserves the existing nullable-timezone null-map handling; I found no line-level correctness issues.

Missing context / blind spots
  • ⚠️ I could not run the new stateless test locally because this checkout has no build directory or clickhouse binary; GitHub checks were still pending when reviewed.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 23, 2026
@scanhex12 scanhex12 self-assigned this Jun 23, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.50% 92.50% +0.00%
Branches 77.50% 77.50% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 12/16 (75.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code

Full report · Diff report

@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

This change is a narrow correctness fix in DateTime/Time-to-String conversion that skips empty strings at NULL positions and falls back to UTC when no timezone is set. The only flagged result, clickbench Q15 (an integer GROUP BY with no datetime-to-string conversion), exercises none of the touched code, so its 11.55% "improvement" is run-to-run variance rather than a real PR effect and has been downgraded. No genuine performance impact is expected from this fix.

clickbench

⚠️ 1 inconclusive

Flagged queries (1 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 15 not_sure 251 222 -11.6% <0.0001 PR only fixes Nullable DateTime->String tz handling; Q15 is integer GROUP BY, no datetime conversion. Off-path, variance

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 097e8c7d-eeeb-4a87-a9ee-02e565282744
  • MIRAI run: 99dbb90c-23fa-411a-8359-76b796ccb64e
  • PR check IDs:
    • clickbench_17577_1782247272
    • clickbench_17583_1782247272
    • clickbench_17585_1782247272
    • tpch_adapted_1_official_17595_1782247272
    • tpch_adapted_1_official_17601_1782247272
    • tpch_adapted_1_official_17612_1782247272

@yariks5s
yariks5s added this pull request to the merge queue Jun 23, 2026
Merged via the queue into master with commit d5846cd Jun 23, 2026
167 checks passed
@yariks5s
yariks5s deleted the yarik/parse-dateTimeBestEffort-nullable branch June 23, 2026 22:21
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 23, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…TimeBestEffort-nullable

Fix best effort DT parsing on NULL strings
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parseDateTimeBestEffort with timezone throws CANNOT_PARSE_DATETIME on NULL rows of toString(Nullable(DateTime64))

3 participants