Skip to content

Make toStartOfInterval return the type of its argument - #122129

Merged
alexey-milovidov merged 27 commits into
masterfrom
to-start-of-interval-preserve-type
Oct 30, 2026
Merged

alexey-milovidov merged 27 commits into
masterfrom
to-start-of-interval-preserve-type

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

toStartOfInterval chose its result type by the interval unit: Date for WEEK and longer, DateTime for DAY down to SECOND, and DateTime64 of the unit's scale for the subsecond units. An argument outside the range of the narrower type was wrapped:

SELECT d, toStartOfInterval(d, toIntervalDay(1)) AS x, toTypeName(x) FROM t32

   ┌──────────d─┬───────────────────x─┬─toTypeName(x)─┐
1. │ 1900-01-01 │ 2036-02-07 06:28:16 │ DateTime      │
2. │ 1969-12-31 │ 2106-02-06 06:28:16 │ DateTime      │
4. │ 2149-06-06 │ 2013-04-29 17:31:44 │ DateTime      │

Now the result has the same type as the argument: Date for Date, Date32 for Date32, DateTime for DateTime, and DateTime64 of the same scale for DateTime64, regardless of the unit. The only exception is a subsecond unit finer than the scale of a DateTime64 argument (e.g. INTERVAL 1500 MILLISECOND for a DateTime64(0)): the result has the scale of the unit then, because the argument scale cannot represent the bucket boundaries. The old behavior stays available with the new setting to_start_of_interval_preserves_argument_type = 0, which is in SettingsChangesHistory for compatibility.

Implementation notes:

  • ToStartOfInterval<unit> returns a day number, seconds, or ticks of a subsecond unit. convertToResultRepresentation converts that value to the result type's representation (fromDayNum / toDayNum / rescaling with an overflow check). The arithmetic fast path for SECOND/MINUTE/HOUR multiplies by the result scale.
  • A Date/DateTime result clamps instead of wrapping, e.g. rounding 1970-01-01 down to a week gives 1970-01-01, not 2149-06-04. A clamping DateTime result is computed through the signed day number, so a boundary before the epoch in a time zone with a negative offset clamps to the timestamp zero instead of the local midnight after it.
  • In the origin overload, when the argument is finer than a subsecond unit, the grid is computed in the argument's scale. Otherwise the part of the origin finer than the unit would be lost: toStartOfInterval(toDateTime64('... 12.987654321', 9), INTERVAL 1 MILLISECOND, toDateTime64('... 12.123456789', 9)) now returns 12.987456789, not 12.987. Before the epoch the old result could even be earlier than the origin.
  • A time zone argument with a Date argument is accepted and has no effect, as for Date32 (but an invalid time zone name is still rejected), so toStartOfInterval(date, INTERVAL 1 DAY, 'tz') keeps working. Its result is now a Date.
  • dateTrunc delegates to toStartOfInterval but passes its own result type, so it is unchanged.
  • The setting also fixes the default behavior behind Wrong primary-key pruning survives #110344 for toStartOfInterval over a Date32 key: missing rows and phantom count() for out-of-range values #116945, since the function no longer wraps. With the legacy setting the wrap is still there.

Existing tests that are about the legacy types (narrowing overflow, enable_extended_results_for_datetime_functions, clamping in the fast path, and the time-zone test that uses toString(..., tz) on the result) now pin the setting to 0. The other affected references changed only in type or scale, except for the origin-overload fix above.

Note on upgrades: a table whose partition or sorting key uses toStartOfInterval with a unit that changes the result type gets a different key type on the new version, e.g. PARTITION BY toStartOfInterval(ts, INTERVAL 1 MONTH) on a DateTime column (was Date, now DateTime), or on a DateTime64 column. Such tables need to_start_of_interval_preserves_argument_type = 0 in the server's default profile. function_date_trunc_return_type_behavior has the same property for dateTrunc.

Requested in #117396 (comment)

Related: #117396
Related: #116945

Changelog category (leave one):

  • Backward Incompatible Change

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

The function toStartOfInterval (and its aliases time_bucket and date_bin) now returns a value of the same type as its argument (Date, Date32, DateTime, or DateTime64 with the same scale) instead of a type determined by the interval unit, which wrapped values outside the range of Date and DateTime. For example, toStartOfInterval(toDate32('1900-01-01'), INTERVAL 1 DAY) returned 2036-02-07 06:28:16 and now returns 1900-01-01. Set to_start_of_interval_preserves_argument_type = 0 to restore the previous behavior, in particular for tables whose partition or sorting key uses toStartOfInterval with a unit that changes the result type.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

🤖 Generated with Claude Code


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

Version info

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

`toStartOfInterval` chose its result type by the interval unit: `Date` for `WEEK` and longer, `DateTime`
for `DAY` down to `SECOND`. A `Date32` or `DateTime64` argument outside the range of the narrower type was
wrapped, e.g. `toStartOfInterval(toDate32('1900-01-01'), INTERVAL 1 DAY)` returned `2036-02-07 06:28:16`,
and the rounding of a `Date` to days produced a `DateTime`.

Now the result has the type of the argument: `Date` for `Date`, `Date32` for `Date32`, `DateTime` for
`DateTime`, and `DateTime64` of the same scale for `DateTime64`. The value computed by `ToStartOfInterval`
(a day number, seconds, or ticks of a subsecond unit) is converted to the representation of the result type.
For the origin overload with an argument finer than a subsecond unit, the grid anchored at the origin is
computed in the scale of the argument, so the part of the origin finer than the unit is kept.

The old behavior is available with `to_start_of_interval_preserves_argument_type = 0`.

#117396 (comment)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [05e0160]

Summary: ✅


AI Review

Summary

toStartOfInterval preserves the input date/time type by default, widens subsecond precision when needed, and retains legacy behavior through to_start_of_interval_preserves_argument_type. The previously reported issues are addressed in the current code. No unresolved findings.

Missing context / blind spots
  • ⚠️ Full CI for head 05e016039444 was still pending when inspected. Local validation used the preceding CI binary, whose toStartOfInterval, dateTrunc, DateTimeTransforms.h, and DateLUTImpl.h sources match the checkout byte for byte; 224 boundary comparisons and 24 scale checks passed. A completed head CI run would close the remaining validation gap.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-backward-incompatible Pull request with backwards incompatible changes label Sep 25, 2026
Comment thread src/Functions/toStartOfInterval.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... label Sep 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 05e016039 with master 80eb86bf2 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 2824be836; 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.

Object file sizes

6 object files changed (+197.92 KiB total), 0 added.

Object file Master PR Δ
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/toStartOfInterval.cpp.o 1.62 MiB 1.81 MiB +194.46 KiB (+11.71%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

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

Job report

…l-preserve-type

Resolve the conflict with the move of the settings changes history into the setting declarations
(ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as
trailing arguments of the `DECLARE` of each setting.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Comment thread src/Functions/toStartOfInterval.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added comp-datetime Date/DateTime/TimeZone datatypes and date-time semantics. and removed comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... labels Sep 27, 2026
alexey-milovidov and others added 3 commits October 3, 2026 08:15
…terval` result type

`toStartOfInterval` now returns the type of its argument, and accepts a time zone
argument with a `Date`, so the `year` and `month` cases with `Date` no longer throw,
and `DateTime64` keeps its type.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122129&sha=713b6bf37d9f4c73a16645c73673ed75055d1032&name_0=PR
PR: #122129

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…` for `Date`, reword the docs

The time zone argument has no effect on a `Date` or `Date32` argument, but a wrong
time zone name is now rejected instead of being silently ignored, in both the
3-argument and the 4-argument (origin) overloads.

The documentation now says that `toStartOfInterval(t, INTERVAL 1 DAY)` rounds to the
same boundary as `toStartOfDay(t)`, since the result types may differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Functions/toStartOfInterval.cpp Resolved
alexey-milovidov and others added 2 commits October 5, 2026 02:00
…ith `to_start_of_interval_preserves_argument_type`

The legacy mode must reproduce the previous results exactly, so the extra
saturation for a result of the argument type is now applied only when the
setting is enabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 CI notes for df40de3:

Comment thread src/Functions/toStartOfInterval.cpp Resolved
@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

The Build (amd_fuzzers) failure on df40de361e7 is clickhouse_fuzzer exceeding the 2 GiB R_X86_64_PC32 reach. It is already fixed on master by #123738 (8ef38edf318, merged 2026-10-04 01:14 UTC). That run started 2026-10-03 10:20 UTC, before the fix, and the current head 2886d0d62b1 contains it. All 52 master runs of this job since 2026-10-04 02:00 UTC passed, so no separate PR is needed. The build on 2886d0d62b1 is still queued.

alexey-milovidov and others added 3 commits October 5, 2026 22:41
…_start_of_interval_preserves_argument_type`

With the setting disabled, a subsecond unit of the `origin` overload already
yields a result of the unit's scale, so the branch could not trigger, but make
the dependency explicit and pin the legacy results of the `origin` overload
(the values of `02916_to_start_of_interval_with_origin` before 26.10) in the test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (939b7771052). It merged cleanly, clickhouse builds, and all 19 toStartOfInterval-related stateless tests pass locally.

The only red job on f2e12265a67 was Fast test (arm_darwin). Its two failures (03312_squashing_with_low_card_mem_usage and 03826_calculate_subcolumn_size_during_merge_tree_read) are NOT_ENOUGH_SPACE errors on the macOS runner, which is not related to this change. The runner free-space problem is tracked by #113605.
Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122129&sha=f2e12265a678a112047d04c1914b97ece5abf81f&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (86a34357570). It merged cleanly, clickhouse builds, and the 22 toStartOfInterval-related stateless tests pass locally.

The only red job on 939b7771052 was Stress test (amd_tsan) with Logical error: '!part.empty()' (STID 2508-34d0), thrown from ASTIdentifier via convertIntoTableExpressionAST: report. It is not related to this PR. Over the last 30 days it also failed on master and on unrelated PRs (#123082, #111250, #120895, #118839, #119662, #118728). The fix is in progress in #122688 (unsubstituted Identifier query parameters that the AST fuzzer puts into row policies).

Comment thread src/Core/Settings.cpp Resolved
Comment thread src/Functions/toStartOfInterval.cpp Resolved
…ale `toStartOfInterval` fast path

A `DateTime64(0)` argument has the same scale multiplier as the legacy `DateTime`
result, so it took the equal-scale fast path, which wrapped out-of-range values
instead of clamping them. Use `saturatingResultCast` there as in the other loops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Functions/toStartOfInterval.cpp Resolved

@yariks5s yariks5s left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR looks good, but I would simplify it by:

  • Using signed timestamps for rounding and clamping only the final result. This fixes the epoch issue and removes the 40-day workaround and second pass
  • Exposing the LUT bounds directly instead of finding them with binary searches
  • Sharing one subsecond-rounding helper that accepts input/output scales and an optional origin
  • Deciding the required precision in the return-type resolver, so execution never silently discards an interval boundary

We can check if it is possible

Also, the last bot's comment make sense. and I found one more issue you can see below

Comment thread src/Functions/toStartOfInterval.cpp Resolved
alexey-milovidov and others added 2 commits October 22, 2026 13:08
…ond bucket boundaries representable

With `to_start_of_interval_preserves_argument_type`, a `DateTime` rounded to days or longer units
used the unsigned overload of `ToStartOfInterval`, which clamps a day before the epoch to the first
day after it. In a time zone with a negative offset that day starts after the timestamp zero, so
the result exceeded the argument (e.g. `toStartOfInterval(toDateTime(0, 'America/New_York'), INTERVAL 1 MONTH)`
returned `18000`). The clamping `DateTime` result now uses the signed overload and saturates the
resulting seconds. The legacy behavior keeps the unsigned overload.

A subsecond unit finer than the scale of a `DateTime64` argument (e.g. `INTERVAL 1500 MILLISECOND`
for a `DateTime64(0)`) produced bucket boundaries that the argument scale could not represent, so
rounding a result again moved it. The result now has the scale of the unit in that case, as in the
legacy behavior. The references of the tests that pinned the narrower scale are updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Functions/toStartOfInterval.cpp Resolved
alexey-milovidov and others added 2 commits October 23, 2026 01:01
…_preserves_argument_type`; fix a performance regression

`dateTrunc` delegates to `toStartOfInterval`, and the delegate inherited the
new setting, so its near-epoch results changed: e.g.
`dateTrunc('day', toDateTime(0, 'Asia/Tokyo'))` returned
`1970-01-01 09:00:00` instead of `1970-01-02 00:00:00`. `dateTrunc` now uses
a `toStartOfInterval` resolver in the legacy mode
(`createLegacyToStartOfIntervalOverloadResolver`), and the test checks the
near-epoch values with the setting enabled and disabled.

With the setting enabled, a `DateTime` argument rounded to a `DateTime`
went through the signed overload of `ToStartOfInterval` for every row, to
clamp the results before the epoch. Where the modular fast path does not
apply (e.g. `Asia/Kolkata` with `INTERVAL 2 SECOND` or `INTERVAL 1 HOUR`),
that made the query up to 1.9 times slower in the performance test
`to_start_of_interval`. When every value of the column is later than the
epoch by more than the length of the interval and two days, the start of
each interval is not before the epoch, and the unsigned overload gives the
same results without clamping, so it is used then.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122129&sha=677620d65df4d4fcf0af56e6d89f80882f06ccbf&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%203%2F6%29
#122129

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The performance test to_start_of_interval was 1.9 times slower for DateTime in Asia/Kolkata with INTERVAL 2 SECOND and INTERVAL 1 HOUR, the cases with no modular fast path. With the setting enabled, every row went through the signed overload of ToStartOfInterval so that results before the epoch could be clamped. Fixed in ea8e0f8: when every value in the column is later than the epoch by more than the interval length plus two days, the unsigned overload is used. It gives the same results there, which I checked across several time zones and units. Local timings now match the legacy mode (0.19 s against 0.19 s, and 0.25 s against 0.25 s).

alexey-milovidov and others added 3 commits October 25, 2026 17:15
…ving the argument type

The test was added on master after this branch was last updated. `kqlBin` with a
calendar-length bin delegates to `toStartOfInterval`, which now returns `DateTime`
for a `DateTime` argument with a month interval instead of `Date`, as intended by
`to_start_of_interval_preserves_argument_type`.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122129&sha=latest&name_0=PR&name_1=Fast%20test
#122129

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master. The only red check (05218_text_index_substreams_opened_lazily in Stateless tests (arm_binary, sequential), triggered by the randomized use_columns_cache 1) is unrelated to this PR and is being fixed in #127781.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 CI on 4ad6341b671: everything passes except Build profile diff. That job failed with LogClusterNotReady: the endpoint never became ready because the CI logs cluster was unavailable, so it is not related to this PR. The fix is in progress in #126200, with a related change in #126296.

@yariks5s, about the four simplifications in your review summary (the inline threads are already resolved):

  • Precision decided in the return-type resolver: done in e5219fc0307. A subsecond unit finer than the argument scale now widens the result scale in the resolver, so execution never drops an interval boundary.
  • Signed timestamps, clamping only the final result: partly adopted. A DateTime result that clamps now goes through the signed Int64 overload of ToStartOfInterval and saturates only the final value. The unsigned overload is still used in two cases. The first is when every value is far enough from the epoch (isFarFromEpoch), because making everything signed made the to_start_of_interval performance test 1.9 times slower. The second is the legacy mode, so that the setting still gives the old results byte for byte. For the same reason, the week/month fast path keeps its small recompute window (the first 40 days after the epoch): it is only entered when the column actually has such values.
  • Exposing the LUT bounds directly: the bounds are private to DateLUTImpl, and lutRangeInScale finds them only once, in a function-local static, so the binary search costs nothing per query. Exposing them means changing DateLUTImpl.h, which almost every translation unit includes. I would rather make that change in a separate small PR than in this one.
  • One shared subsecond-rounding helper: a reasonable follow-up refactoring. I kept it out of this PR so that its diff stays focused on the type change and the boundary semantics.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (60d690f03a4) with no conflicts. clickhouse builds, and all 23 stateless tests this PR adds or changes pass locally.

The only red job on 4ad6341b671 was Build profile diff. It failed with LogClusterNotReady, an outage of the CI logs cluster that has nothing to do with this PR. It is tracked in #120462, and fixes are open in #126200 and #128067.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Merged master (80eb86bf2a2) with no conflicts and pushed 05e01603944. Master did not touch any file this PR changes.

Both red tests on 60d690f03a4 are unrelated to this PR, and master already fixes them:

  • 05397_clickhouse_local_locked_path_untouched in Fast test (arm_darwin): master now skips the test on macOS, because the runner has no flock(1) (Skip 05397_clickhouse_local_locked_path_untouched on macOS #128088).
  • 05055_format_schema_source_query_background_access in Stateless tests (arm_binary, AsyncInsert, s3 storage, parallel): the randomized session_timezone (Africa/Juba) made the test fail near midnight. Master made it time zone independent in 39c63970c98.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 30, 2026
Merged via the queue into master with commit 19fe57f Oct 30, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the to-start-of-interval-preserve-type branch October 30, 2026 08:49
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 30, 2026
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Nov 6, 2026
…e32 range they wrap

With the legacy result types (to_start_of_interval_preserves_argument_type = 0,
which any compatibility below 26.11 restores, and the only behaviour of every
release up to 26.10; for dateTrunc, function_date_trunc_return_type_behavior = 1)
a Date32 argument is rounded into Date (WEEK..YEAR) or DateTime (DAY) and stored
with a plain cast, so dates before 1970 and after 2149 (2106 for DateTime) wrap.
getMonotonicityForRange nevertheless returned is_monotonic and
is_always_monotonic unconditionally, so:
- KeyCondition mapped mark ranges through a decreasing function and pruned
  granules wrongly in both directions (ORDER BY d: rows dropped, DESC: kept);
- matchesExactContinuousRange derived exact ranges through it, so the exact
  count path counted rows without the filter, and when a skip index had
  trimmed the selected ranges at analysis time the exact range ended past the
  selected one: chassert(exact_ranges[i].end <= range.end) (AST fuzzer,
  STID 2508-5221);
- sort-order propagation treated the rounding as order preserving, so
  ORDER BY toStartOfInterval(d, ...) returned rows out of order;
- KeyCondition pushed a condition on d through a sorting or partition key
  toStartOfInterval(d, ...), whose stored values wrap, and skipped matching
  granules and partitions.

When the argument, with LowCardinality and Nullable removed, is Date32 and the
result type is Date or DateTime, getMonotonicityForRange now rounds both
bounds of the range with the same ToStartOfInterval<unit>::execute overload
the function executes. The rounding is non-decreasing in that wide type, so
the range maps without wrapping iff both rounded bounds fit the result type
([0, 65535] days for Date, [0, UInt32 max] seconds for DateTime in the
result's time zone). Then only is_monotonic is claimed for the range;
otherwise, and for an unbounded or non-integer bound or a non-constant
interval, nothing is claimed. is_always_monotonic is never claimed for these
results: the function is not monotonic on its whole domain, and the functions
stress test treats is_always_monotonic on some ranges with is_monotonic false
on others as broken monotonicity. is_always_monotonic_where_defined is not
claimed either: a sorting or partition key toStartOfInterval(d32, ...) stores
the wrapped values, so a condition on d pushed through it pruned matching rows
(the reasoning of ClickHouse#125960 for toDate).

Values, result types and settings do not change: saturating the Date32 values
was rejected during the review of ClickHouse#110344 (see ClickHouse#116945), because the legacy
setting exists to restore the old results exactly. This re-applies the
monotonicity guard of the closed ClickHouse#117396 to the legacy result types that
ClickHouse#122129 kept.

Cost, legacy mode with a Date32 key only: a range whose rounding wraps is not
pruned through the function, and the exact count and ordering optimizations
are not used for these narrowing roundings, and a condition on the column is
not pushed through such a key expression.

Closes ClickHouse#116945

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 8, 2026
Since ClickHouse#122129 (`to_start_of_interval_preserves_argument_type`, default on),
`toStartOfInterval` returns the type of its argument, so `kqlBin` over a
`DateTime64` with a calendar interval now gives `2026-08-01 00:00:00.0000000`
instead of the `Date` `2026-08-01`. The unwrapped form gives the same value,
so the `LowCardinality` arm stays transparent; only the expected value moves.

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

comp-datetime Date/DateTime/TimeZone datatypes and date-time semantics. pr-backward-incompatible Pull request with backwards incompatible changes 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.

4 participants