Skip to content

Restore JSONExtract DateTime parsing under old compatibility - #128048

Merged
fm4v merged 3 commits into
masterfrom
nik/json-extract-datetime-compat
Oct 31, 2026
Merged

fm4v merged 3 commits into
masterfrom
nik/json-extract-datetime-compat

Conversation

@fm4v

@fm4v fm4v commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Related: #109252

#109252 (26.8) made the JSONExtract family parse DateTime / DateTime64 values according to cast_string_to_date_time_mode instead of date_time_input_format, without a compatibility gate. Both settings default to best_effort since 26.5, but with compatibility below 26.5 cast_string_to_date_time_mode is basic. A user who pins compatibility and sets date_time_input_format = 'best_effort' explicitly (as ClickHouse Cloud does for every service) sees ISO 8601 values silently turn into the epoch after the upgrade to 26.8, because JSONExtract returns the default value when parsing fails:

SET compatibility = '23.9', date_time_input_format = 'best_effort';
SELECT JSONExtract('{"createdAt":"2026-10-19T07:30:26.743Z"}', 'createdAt', 'DateTime64(3)');
-- 26.6: 2026-10-19 07:30:26.743
-- 26.8: 1970-01-01 00:00:00.000

Materialized views using this pattern write epoch values without any error. A scan of ClickHouse Cloud found about 19k materialized views on about 590 services that call JSONExtract with a DateTime type under these settings.

This PR adds the setting json_extract_use_cast_string_to_date_time_mode (enabled by default) that keeps the new behavior, while compatibility with versions before 26.8 restores the previous one. The setting is also added to the query condition cache key, next to the other settings captured by JSONOverloadResolver.

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):

Fix a regression in 26.8: with compatibility set to a version before 26.5 and date_time_input_format = 'best_effort', JSONExtract silently returned 1970-01-01 00:00:00 for ISO 8601 DateTime values. compatibility with versions before 26.8 now restores the old behavior, controlled by the new setting json_extract_use_cast_string_to_date_time_mode.


Workflow [PR]
Sync PR [sync-upstream/pr/128048]

Version info

  • Merged into: 26.11.1.969-master (included in 26.11 and later)

#109252 made the `JSONExtract` family parse `DateTime` values according to `cast_string_to_date_time_mode` instead of `date_time_input_format`, without a compatibility gate. When `compatibility` is below 26.5, `cast_string_to_date_time_mode` is `basic`, so with `date_time_input_format = 'best_effort'` set explicitly, ISO 8601 values like `2026-10-19T07:30:26.743Z` silently become `1970-01-01 00:00:00.000` after the upgrade to 26.8, and materialized views write epoch values.

Add the setting `json_extract_use_cast_string_to_date_time_mode`, enabled by default and disabled by `compatibility` with versions before 26.8.
@fm4v fm4v added pr-bugfix Pull request with bugfix, not backported by default v26.8-must-backport v26.9-must-backport v26.10-must-backport labels Oct 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [469f496]

Summary: ✅


AI Review

Summary

PR #128048 restores JSONExtract parsing through date_time_input_format when compatibility is below 26.8, preserves the current default behavior, and includes the new setting in the query condition cache key. No actionable findings at head 469f496303231bd1b520a37de6076c1f27007c7e. The added regression test passes in the current head's Fast test report.

Final Verdict

Status: ✅ Approve. No changes requested.

@clickhouse-gh clickhouse-gh Bot added the comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... label Oct 28, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 469f49630 with master 3c82fa8cc (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

9 translation units recompiled, 32 s compile time in total, 9 of them have a recent master baseline.

Job report

@fm4v
fm4v added this pull request to the merge queue Oct 31, 2026
Merged via the queue into master with commit 4c45be6 Oct 31, 2026
180 checks passed
@fm4v
fm4v deleted the nik/json-extract-datetime-compat branch October 31, 2026 14:08
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 31, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 31, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 31, 2026
Backport #128048 to 26.10: Restore JSONExtract DateTime parsing under old compatibility
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 1, 2026
robot-clickhouse added a commit that referenced this pull request Nov 1, 2026
Cherry pick #128048 to 26.9: Restore JSONExtract DateTime parsing under old compatibility
robot-clickhouse added a commit that referenced this pull request Nov 1, 2026
robot-clickhouse-ci-1 added a commit that referenced this pull request Nov 1, 2026
Cherry pick #128048 to 26.8: Restore JSONExtract DateTime parsing under old compatibility
robot-clickhouse added a commit that referenced this pull request Nov 1, 2026
alexey-milovidov pushed a commit to Onyx2406/ClickHouse that referenced this pull request Nov 1, 2026
…ng_to_date_time_mode description

ClickHouse#128048 added the setting json_extract_use_cast_string_to_date_time_mode with a
description that links date_time_input_format on the formats/input-format page.
That setting is rendered on formats/date-time. The docs generator leaves links
into another settings family unchanged, so the daily docs regeneration PR
ClickHouse#128351 fails "Check internal links and anchors" in "Docs check (Mintlify)":

  [ERROR] reference/settings/formats/input-format#date_time_input_format (at 967:352) | Cannot find fragment

ClickHouse#128048 changed only src/, so its own CI did not run the docs check.

Point the link at /reference/settings/formats/date-time#date_time_input_format,
the target the other six source links to this setting already use
(registerDataTypeDateTime.cpp, HiveTextRowOutputFormat.cpp).

Validated by regenerating the docs with a build with and without the change
(autogenerate_docs.py --write --docs-dir docs) and running lychee_check.py
--mode links: 1 error (the one above, same position) without, 0 with.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@fm4v fm4v self-assigned this Nov 2, 2026
PedroTadim added a commit that referenced this pull request Nov 3, 2026
…History for 26.8

The backport added the setting to Settings.cpp (with master's inline history), but on 26.8 both the
`compatibility` mechanism and the 03999 guard read src/Core/SettingsChangesHistory.cpp, which had no
entry for it. Add the 26.8 entry {false, true} matching master's inline `{"26.8", false, true}`.

Fixes two stateless failures:
- 03999_stateless_settings_history: "PLEASE ADD THE NEW SETTING TO SettingsChangesHistory.cpp".
- 05457_json_extract_datetime_compatibility: `SET compatibility = '23.9'` now resets the setting to
  its pre-26.8 value (false), restoring `date_time_input_format` parsing as the test expects.

#128467
#128048
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128467&sha=4b790cb064df2c7c5e1712d22b15f34aa9a832af&name_0=BackportPR

Co-Authored-By: Claude Opus 4.8 <[email protected]>
PedroTadim added a commit that referenced this pull request Nov 3, 2026
…History for 26.9

Same fix as the 26.8 backport. The setting was added to Settings.cpp (with master's inline history),
but 26.9's `compatibility` mechanism and the 03999 guard read src/Core/SettingsChangesHistory.cpp,
which had no entry. Add the 26.8-section entry {false, true} matching master's inline `{"26.8", ...}`
so `compatibility` before 26.8 restores the old `date_time_input_format` parsing.

Fixes 03999_stateless_settings_history and 05457_json_extract_datetime_compatibility.

#128464
#128048
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=128464&sha=b1618c347cb2f60298b4d568bbf8d303767bce86&name_0=BackportPR

Co-Authored-By: Claude Opus 4.8 <[email protected]>
clickhouse-gh Bot added a commit that referenced this pull request Nov 3, 2026
Backport #128048 to 26.8: Restore JSONExtract DateTime parsing under old compatibility
clickhouse-gh Bot added a commit that referenced this pull request Nov 3, 2026
Backport #128048 to 26.9: Restore JSONExtract DateTime parsing under old compatibility
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…History for 26.8

The backport added the setting to Settings.cpp (with master's inline history), but on 26.8 both the
`compatibility` mechanism and the 03999 guard read src/Core/SettingsChangesHistory.cpp, which had no
entry for it. Add the 26.8 entry {false, true} matching master's inline `{"26.8", false, true}`.

Fixes two stateless failures:
- 03999_stateless_settings_history: "PLEASE ADD THE NEW SETTING TO SettingsChangesHistory.cpp".
- 05457_json_extract_datetime_compatibility: `SET compatibility = '23.9'` now resets the setting to
  its pre-26.8 value (false), restoring `date_time_input_format` parsing as the test expects.

#128467
#128048
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128467&sha=4b790cb064df2c7c5e1712d22b15f34aa9a832af&name_0=BackportPR

Co-Authored-By: Claude Opus 4.8 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…History for 26.9

Same fix as the 26.8 backport. The setting was added to Settings.cpp (with master's inline history),
but 26.9's `compatibility` mechanism and the 03999 guard read src/Core/SettingsChangesHistory.cpp,
which had no entry. Add the 26.8-section entry {false, true} matching master's inline `{"26.8", ...}`
so `compatibility` before 26.8 restores the old `date_time_input_format` parsing.

Fixes 03999_stateless_settings_history and 05457_json_extract_datetime_compatibility.

#128464
#128048
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=128464&sha=b1618c347cb2f60298b4d568bbf8d303767bce86&name_0=BackportPR

Co-Authored-By: Claude Opus 4.8 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.8-must-backport v26.9-must-backport v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants