Skip to content

Fix a bug during the interval type conversion - #105058

Merged
nihalzp merged 7 commits into
masterfrom
yarik/fix-interval-conversion-bug
Jun 25, 2026
Merged

nihalzp merged 7 commits into
masterfrom
yarik/fix-interval-conversion-bug

Conversation

@yariks5s

@yariks5s yariks5s commented May 15, 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 bugs when using CAST from smaller to larger interval units. Closes #104986

Version info

  • Merged into: 26.7.1.63

@clickhouse-gh

clickhouse-gh Bot commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [422e985]

Summary: ✅


AI Review

Summary

This PR fixes interval-to-interval CAST from smaller to larger units by applying the boundary factors from from + 1 through to, which matches the existing interval_conversions layout and preserves the backward conversion path. The added stateless regression now covers adjacent and multi-step conversions across Nanosecond through Year, including the previously missing Month/Quarter/Year segment. I found no current correctness blockers or major issues.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label May 15, 2026
@nihalzp nihalzp self-assigned this May 15, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

This was fixed by #105146. Let's update the branch.

@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Dear @nihalzp, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@nihalzp nihalzp self-assigned this Jun 18, 2026
Add focused regression coverage for the `Month`/`Quarter`/`Year` tail of
`IntervalKind`, which is controlled by the same shifted forward-conversion
loop in `ConvertImpl` but was previously untested: `Week`/`Month`/`Quarter`/
`Year` adjacent conversions in both directions and multi-step `Month`->`Year`
and `Week`->`Year`. These cases produced wrong results before the fix (e.g.
`CAST(toIntervalMonth(3) AS IntervalQuarter)` returned `0` instead of `1`).

Also add `-- { echo }` so the reference file shows each query next to its
result, as requested in review.
@clickhouse-gh

clickhouse-gh Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.20% -0.10%
Functions 92.60% 92.50% -0.10%
Branches 77.50% 77.50% +0.00%

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

Full report · Diff report

@nihalzp
nihalzp added this pull request to the merge queue Jun 25, 2026
Merged via the queue into master with commit 639a466 Jun 25, 2026
329 of 330 checks passed
@nihalzp
nihalzp deleted the yarik/fix-interval-conversion-bug branch June 25, 2026 13:10
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 25, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Hi — this looks like a backport candidate for 26.1, 26.2, 26.3, 26.4, 26.5. I ran this PR's own regression test against each branch's binary and the bug reproduces there (the fix isn't present yet).

zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…al-conversion-bug

Fix a bug during the interval type conversion
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.

interval_conversions vector has wrong values causing CAST from smaller to larger interval units to return incorrect results

5 participants