fix(clickhouse): use parseDateTime64BestEffort to preserve millisecond precision#10533
Open
majiayu000 wants to merge 2 commits intocube-js:masterfrom
Open
fix(clickhouse): use parseDateTime64BestEffort to preserve millisecond precision#10533majiayu000 wants to merge 2 commits intocube-js:masterfrom
majiayu000 wants to merge 2 commits intocube-js:masterfrom
Conversation
…d precision Replace parseDateTimeBestEffort with parseDateTime64BestEffort(value, 3) in ClickHouseQuery to prevent silent truncation of milliseconds in pre-aggregation WHERE clauses, time series queries, and Tesseract timestamp literals. Fixes cube-js#10326 Signed-off-by: majiayu000 <1835304752@qq.com>
…Cast Update 3 comments that still referenced parseDateTimeBestEffort after the function was replaced with parseDateTime64BestEffort. Add unit test for dateTimeCast() to verify both timezone and non-timezone paths use DateTime64 with precision 3. Signed-off-by: majiayu000 <1835304752@qq.com>
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.
Check List
Issue Reference this PR resolves
Fixes #10326
Description of Changes Made
Replace all occurrences of
parseDateTimeBestEffortwithparseDateTime64BestEffort(…, 3)inClickHouseQuery.tsto preserve millisecond precision in pre-aggregation WHERE clauses and time series queries.parseDateTimeBestEffortreturnsDateTime(second precision), which silently truncates milliseconds from timestamps like2024-01-01T00:00:00.000.parseDateTime64BestEffortis a drop-in replacement that returnsDateTime64with configurable sub-second precision. Precision 3 = milliseconds, consistent with the timezone-aware branch that already usestoDateTime64(..., 3).Changes:
dateTimeCast()— primary fix for the reported issue. WHERE clause timestamp casts now preserve milliseconds.seriesSql()— time series date_from/date_to parsing also updated for consistency.sqlTemplates()— Tesseract timestamp_literal and time_series_select templates updated.dateTimeCast()verifying the output containsparseDateTime64BestEffort.User-defined SQL in FILTER_PARAMS (e.g., in test fixtures) is intentionally left unchanged.