Skip to content

Fix/time truncate3.6#34463

Merged
guanshengliang merged 7 commits into3.3.6from
fix/timeTruncate3.6
Feb 5, 2026
Merged

Fix/time truncate3.6#34463
guanshengliang merged 7 commits into3.3.6from
fix/timeTruncate3.6

Conversation

@facetosea
Copy link
Copy Markdown
Contributor

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Copilot AI review requested due to automatic review settings February 2, 2026 00:31
@facetosea facetosea requested a review from dapan1121 as a code owner February 2, 2026 00:31
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @facetosea, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the accuracy and robustness of time calculation and truncation utilities. It resolves issues related to incorrect month/year arithmetic and refines the application of intervals and offsets, particularly for calendar-based units. These changes ensure more precise time series data processing and prevent unexpected date shifts.

Highlights

  • Improved Month/Year Calculation: The taosTimeAdd function has been updated to correctly handle calculations involving negative month values, preventing potential errors in year and month arithmetic.
  • Refined Time Truncation Logic: The taosTimeTruncate function now applies interval and offset calculations in a corrected sequence, ensuring accurate determination of time window boundaries, especially with sliding intervals.
  • Date Shifting Prevention for Intervals: A specific logic block has been introduced in taosTimeGetIntervalEnd to address 'date shifting problems' when dealing with month or year units, ensuring calendar-aware interval end calculations.
  • New Test Case for Time Truncation: A new test case has been added to commonTests.cpp to validate the corrected behavior of the taosTimeTruncate function under specific conditions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces several fixes related to time calculations, particularly for taosTimeTruncate and taosTimeAdd. The changes correctly handle negative month offsets and the application of intervals and offsets for calendar units. A new test case for taosTimeTruncate has been added, which is a good step towards ensuring correctness. I've identified a potential data truncation and overflow issue in taosTimeAdd and provided a suggestion to address it.

Comment thread source/common/src/ttime.c Outdated
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 updates time-window calculations to handle month/year arithmetic and offset behavior more correctly, and adds a regression test around taosTimeTruncate().

Changes:

  • Fix month/year addition in taosTimeAdd() to correctly normalize negative month values.
  • Adjust taosTimeTruncate() window-end computation and enhance taosTimeGetIntervalEnd() to better handle month/year “date shifting” with offsets.
  • Add a new unit test for taosTimeTruncate().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
source/common/src/ttime.c Fixes calendar month/year arithmetic, adjusts truncate/end calculations for offset + calendar units.
source/common/test/commonTests.cpp Adds a regression test covering taosTimeTruncate() behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/common/test/commonTests.cpp
Comment thread source/common/test/commonTests.cpp
Comment thread source/common/src/ttime.c Outdated
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

facetosea and others added 3 commits February 3, 2026 10:09
@guanshengliang guanshengliang merged commit cfcbcaf into 3.3.6 Feb 5, 2026
11 of 12 checks passed
@guanshengliang guanshengliang deleted the fix/timeTruncate3.6 branch February 5, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants