Fix ALIAS columns not applying timezone conversion for DateTime types in analyzer#101043
Merged
alexey-milovidov merged 2 commits intomasterfrom Mar 29, 2026
Merged
Fix ALIAS columns not applying timezone conversion for DateTime types in analyzer#101043alexey-milovidov merged 2 commits intomasterfrom
alexey-milovidov merged 2 commits intomasterfrom
Conversation
… in analyzer The analyzer used `DataType::equals` to check if a cast was needed for ALIAS columns, but `DateTime` and `DateTime64` `equals` methods intentionally ignore timezone differences. This meant `DateTime64(3, 'Europe/Berlin') ALIAS timestamp` (where `timestamp` is `DateTime64(3)`) would skip the cast, returning the raw UTC value with just the timezone label changed. Use `getName()` string comparison instead (matching the old interpreter behavior) so timezone differences are detected and a proper `_CAST` is applied. Closes #76787 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Workflow [PR], commit [a0b3a11] Summary: ✅ AI ReviewSummaryThis PR fixes a real analyzer correctness issue for Missing context
ClickHouse Rules
Final Verdict
|
Contributor
LLVM Coverage Report
Changed lines: 92.86% (13/14) · Uncovered code |
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.
The analyzer used
DataType::equalsto check if a cast was needed for ALIAS columns, butDateTimeandDateTime64equalsmethods intentionally ignore timezone differences. This meant an alias likeDateTime64(3, 'Europe/Berlin') ALIAS timestamp(wheretimestampisDateTime64(3)) would skip the cast, returning the raw UTC value with just the timezone label changed — no actual timezone conversion.Changed to
getName()string comparison (matching the old interpreter behavior) so timezone differences are detected and a proper_CASTis applied.Closes #76787
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix ALIAS columns with
DateTime/DateTime64types not applying timezone conversion when the declared timezone differs from the expression timezone.Documentation entry for user-facing changes