Skip to content

merge: from 3.3.6 to 3.3.8#34505

Merged
guanshengliang merged 3 commits into3.3.8from
merge/3.3.6to3.3.8
Feb 5, 2026
Merged

merge: from 3.3.6 to 3.3.8#34505
guanshengliang merged 3 commits into3.3.8from
merge/3.3.6to3.3.8

Conversation

@guanshengliang
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?

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @guanshengliang, 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 integrates updates from version 3.3.8, primarily focusing on enhancing the system's time-related functionalities. It introduces more robust handling of calendar-based time intervals and refines time window calculations for improved accuracy and consistency. The changes also include structural improvements by centralizing time utility functions, alongside expanding test coverage for critical time-handling logic and improving existing disk allocation tests.

Highlights

  • Time Window Calculation Refactoring: The logic for calculating time window starts and ends has been refactored. The getNextTimeWindowStart and taosTimeGetIntervalEnd functions were moved from executil.c and taosTimeTruncate respectively into ttime.c and ttime.h, improving modularity and centralizing time-related utilities.
  • Calendar Time Unit Conversion: A new function, convertCalendarTimeFromUnitToPrecision, has been introduced to accurately convert calendar-based durations (months and years) into a minimal continuous time length with a specified precision. This is crucial for consistent comparison of interval and sliding windows, especially when dealing with mixed time units.
  • Improved taosTimeAdd for Months: The taosTimeAdd function has been enhanced to correctly handle scenarios involving the addition of negative month durations, ensuring accurate time calculations across year boundaries.
  • Enhanced Interval Window Validation: The parser's checkIntervalWindow function now includes more robust validation for interval and sliding window durations. It specifically addresses comparisons between calendar-based units and fixed time units, utilizing the new convertCalendarTimeFromUnitToPrecision function for accurate checks.
  • Test Coverage Expansion: A new test case has been added for taosTimeTruncate to verify its behavior with specific interval and offset configurations, and disk allocation tests in TFS were improved for more robust validation of round-robin behavior.

🧠 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.

Changelog
  • include/common/ttime.h
    • Added declarations for getNextTimeWindowStart and convertCalendarTimeFromUnitToPrecision.
  • include/libs/executor/executor.h
    • Removed the declaration of getNextTimeWindowStart as its definition was moved to ttime.h.
  • source/common/src/ttime.c
    • Included tcommon.h for common definitions.
    • Implemented convertCalendarTimeFromUnitToPrecision to convert calendar units (months/years) to a specified time precision.
    • Modified taosTimeAdd to correctly handle negative month additions by adjusting year and month values.
    • Implemented getNextTimeWindowStart and taosTimeGetIntervalEnd functions.
    • Refactored taosTimeTruncate to leverage the newly implemented getNextTimeWindowStart and taosTimeGetIntervalEnd functions for clearer logic.
  • source/common/test/commonTests.cpp
    • Added a new test case TEST(testCase, function_taosTimeTruncate) to validate the taosTimeTruncate function.
  • source/libs/executor/src/executil.c
    • Removed the implementation of getNextTimeWindowStart.
    • Updated getNextTimeWindow to use the new taosTimeGetIntervalEnd function.
  • source/libs/parser/src/parTranslater.c
    • Refactored error handling within checkIntervalWindow using TAOS_CHECK_GOTO macros for consistency.
    • Updated checkIntervalWindow to use convertCalendarTimeFromUnitToPrecision for accurate comparison of sliding and interval durations when units are mixed.
    • Added centralized error reporting for interval window checks via an _exit label.
  • source/libs/tfs/test/tfsTest.cpp
    • Introduced a rootArr for clearer test path management.
    • Improved assertions in tfsAllocDisk tests to verify round-robin disk allocation and path correctness more robustly.
Activity
  • The pull request is a merge from version 3.3.6 to 3.3.8, indicating an integration of changes from a newer release.
  • The primary activity involves significant refactoring and enhancement of time-related utility functions, particularly for handling calendar-based time intervals and window calculations.
  • New functions and logic have been introduced to improve the precision and correctness of time unit conversions and interval validations.
  • Existing test cases have been expanded and new ones added to ensure the reliability of the updated time functions and disk allocation mechanisms.
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 appears to be a merge that incorporates several valuable bug fixes and refactorings, primarily focused on time handling functionalities. The changes are positive, enhancing both the correctness and maintainability of the codebase. Key improvements include a critical fix for handling negative month offsets in taosTimeAdd, a logical refactoring of taosTimeTruncate for better time window calculations, and the introduction of convertCalendarTimeFromUnitToPrecision to correctly manage comparisons between different time units. Additionally, moving time-related utilities to ttime.c improves code organization. I have a few minor suggestions for further refinement.

Comment thread source/common/src/ttime.c
Comment on lines +782 to +789
int64_t y = mon / 12;
int64_t m = mon % 12;
if (m < 0) {
m += 12;
y -= 1;
}
tm.tm_year = (int)y;
tm.tm_mon = (int)m;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The logic to handle negative month offsets is correct. However, it can be simplified and made branchless, which can be slightly more efficient. Consider using modular arithmetic to handle negative results of the modulo operator.

  int64_t m = (mon % 12 + 12) % 12;
  int64_t y = (mon - m) / 12;
  tm.tm_year = (int)y;
  tm.tm_mon = (int)m;

interval.timeRange.skey = INT64_MIN;
interval.timeRange.ekey = INT64_MAX;
int64_t res = taosTimeTruncate(ts, &interval);
ASSERT_LE(res, 1633450000000);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The assertion ASSERT_LE(res, 1633450000000) is quite weak as it only checks that the truncated timestamp is not after the original one. To make this test more effective and ensure the correctness of taosTimeTruncate, it would be better to assert against a specific, expected timestamp value. For example: ASSERT_EQ(res, expected_timestamp);.

Comment on lines +7489 to +7497
int64_t interverNano = 0, slidingNano = 0;
code = convertCalendarTimeFromUnitToPrecision(pInter->datum.i, pInter->unit, precision, &interverNano);
TAOS_CHECK_GOTO(code, &lino, _exit);

// pSliding->datum.i is already in precision unit
slidingNano = pSliding->datum.i;

if (slidingNano > interverNano) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There's a typo in the variable name interverNano. It should be intervalNano for clarity and consistency. This typo appears on lines 7489, 7490, and 7496.

        int64_t intervalNano = 0, slidingNano = 0;
        code = convertCalendarTimeFromUnitToPrecision(pInter->datum.i, pInter->unit, precision, &intervalNano);
        TAOS_CHECK_GOTO(code, &lino, _exit);

        // pSliding->datum.i is already in precision unit
        slidingNano = pSliding->datum.i;

        if (slidingNano > intervalNano) {
          return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_BIG);
        }

@guanshengliang guanshengliang merged commit f98efca into 3.3.8 Feb 5, 2026
10 of 11 checks passed
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.

3 participants