Skip to content

Fix a small bug on DT64->T->T64 conversion#90324

Merged
yariks5s merged 3 commits intomasterfrom
yarik/fix-time-time64-conversion-bug
Nov 21, 2025
Merged

Fix a small bug on DT64->T->T64 conversion#90324
yariks5s merged 3 commits intomasterfrom
yarik/fix-time-time64-conversion-bug

Conversation

@yariks5s
Copy link
Copy Markdown
Member

@yariks5s yariks5s commented Nov 18, 2025

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 a bug where SELECT CAST(CAST(now(), 'Time'), 'Time64') was producing incorrect result. Closes #88349

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Nov 18, 2025

Workflow [PR], commit [fecfcbe]

Summary:

job_name test_name status info comment
Build (amd_compat) failure
Cmake configuration failure cidb
Stateless tests (amd_binary, ParallelReplicas, s3 storage, parallel) failure
02494_query_cache_ignore_output_settings FAIL cidb
Integration tests (amd_tsan, 3/6) failure
test_backup_restore_s3/test.py::test_backup_to_s3_different_credentials[data_file_name_from_first_file_name-native_multipart] FAIL cidb
AST fuzzer (amd_tsan) failure
Logical error: 'Unexpected return type from isNotDistinctFrom. Expected UInt8. Got Nothing. Action: FAIL cidb
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: FAIL cidb
BuzzHouse (arm_asan) failure
Received signal 11 FAIL cidb
BuzzHouse (amd_ubsan) failure
/home/ubuntu/actions-runner/_work/ClickHouse/ClickHouse/src/Common/ProfileEvents.cpp:1512:64: runtime error: signed integer overflow: -9085927566061029451 - 9016420377433257301 cannot be represented in type 'Increment' (aka 'long') FAIL cidb

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Nov 18, 2025
@yariks5s
Copy link
Copy Markdown
Member Author

Provided test requires #90310

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the conversion chain from DateTime64 to Time to Time64, where intermediate Time values (represented as seconds) were incorrectly treated as day numbers during the final conversion to Time64.

Key Changes:

  • Fixed ToTime64Transform::execute(Int32 d, ...) to correctly preserve Time values (seconds) instead of misinterpreting them as day numbers
  • Added test cases to verify the fix for the specific conversion path: DateTime64 -> Time -> Time64

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Functions/FunctionsConversion.h Fixed ToTime64Transform::execute(Int32, ...) to directly use seconds value instead of incorrectly converting through fromDayNum
tests/queries/0_stateless/03365_time_to_time64_conv_bug.sql Added test queries for DateTime64->Time->Time64 conversion chain
tests/queries/0_stateless/03365_time_to_time64_conv_bug.reference Expected results showing correct time preservation through conversion chain

@yariks5s
Copy link
Copy Markdown
Member Author

@yariks5s yariks5s added this pull request to the merge queue Nov 21, 2025
Merged via the queue into master with commit 98c52db Nov 21, 2025
124 of 132 checks passed
@yariks5s yariks5s deleted the yarik/fix-time-time64-conversion-bug branch November 21, 2025 15:53
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 21, 2025
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.

Bad cast from Time to Time64

4 participants