Skip to content

feat!: implement interval type by multiple structs#4772

Merged
evenyag merged 19 commits intomainfrom
reimpl-interval
Oct 14, 2024
Merged

feat!: implement interval type by multiple structs#4772
evenyag merged 19 commits intomainfrom
reimpl-interval

Conversation

@evenyag
Copy link
Copy Markdown
Contributor

@evenyag evenyag commented Sep 26, 2024

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

This PR uses three dedicated interval structs to replace the old all-in-one interval struct.

  • IntervalYearMonth
  • IntervalDayTime
  • IntervalMonthDayNano

Before this PR, some behaviors of the interval struct is incorrect as it always assumes a month has 30 days and a year has 365 days.

Upgrading arrow requires this feature.

It also removes the datetime support for date_add and date_sub as arrow doesn't support datetime arithmetic.

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.

Summary by CodeRabbit

  • New Features

    • Introduced specific methods for adding and subtracting intervals in Date, DateTime, Timestamp, and Interval modules, enhancing clarity and precision.
    • Added new interval types: IntervalYearMonth, IntervalDayTime, and IntervalMonthDayNano.
  • Bug Fixes

    • Removed unsupported DateTime type handling in DateAddFunction and DateSubFunction.
  • Refactor

    • Streamlined interval handling and conversion processes across various modules, improving type safety and modularity.
  • Tests

    • Updated test cases to reflect new interval types and methods.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 26, 2024

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes primarily focus on enhancing the handling of interval types across multiple files in the codebase. The Value enum is refined to include specific interval variants, and various functions are updated to reflect this new structure. Additionally, the DateAddFunction and DateSubFunction implementations are simplified by removing support for DateTime, while new methods for manipulating dates and timestamps with specific intervals are introduced. The overall modifications aim to improve type specificity and streamline interval operations.

Changes

File Path Change Summary
src/api/src/helper.rs Updated Value enum to include specific interval types; modified functions for interval handling.
src/common/function/src/scalars/date/date_add.rs Removed DateTime support from DateAddFunction; simplified addition logic using Arrow library.
src/common/function/src/scalars/date/date_sub.rs Removed DateTime support from DateSubFunction; simplified subtraction logic using Arrow library.
src/common/grpc/src/select.rs Updated import and usage of interval conversion functions to reflect new specific types.
src/common/time/src/date.rs Introduced specific methods for adding and subtracting intervals; removed generic interval methods.
src/common/time/src/datetime.rs Added specific methods for interval addition and subtraction; removed generic interval methods.
src/common/time/src/interval.rs Refactored interval representation into specific types; added methods for creation and conversion.
src/common/time/src/lib.rs Updated public exports to include specific interval types instead of a generic interval type.
src/common/time/src/timestamp.rs Introduced specific methods for interval addition and subtraction; removed generic interval methods.
src/common/time/src/timestamp_millis.rs No changes reported.

Possibly related PRs

  • feat: add json data type #4619: This PR involves modifications to the src/api/src/helper.rs file, which shares a focus on handling data types, specifically JSON data types, in the same context as the main PR.

Suggested reviewers

  • WenyXu
  • v0y4g3r
  • waynexia

🐇 In the land of code where intervals play,
New types emerge, brightening the day.
With methods refined, and logic so clear,
We hop through the changes, spreading good cheer!
Let's celebrate precision, in every small part,
For in this code garden, we craft with our heart! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions Bot added docs-not-required This change does not impact docs. breaking-change This pull request contains breaking changes. labels Sep 26, 2024
@evenyag
Copy link
Copy Markdown
Contributor Author

evenyag commented Sep 26, 2024

@coderabbitai summary

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 26, 2024

✅ Actions performed

Summary regeneration triggered.

@evenyag evenyag marked this pull request as ready for review September 26, 2024 07:57
@evenyag evenyag requested review from a team, v0y4g3r, waynexia and zhongzc as code owners September 26, 2024 07:57
@evenyag evenyag requested review from WenyXu and discord9 September 26, 2024 07:57
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 26, 2024

Codecov Report

Attention: Patch coverage is 65.22293% with 273 lines in your changes missing coverage. Please review.

Project coverage is 84.45%. Comparing base (5c64f0c) to head (73bfcd1).
Report is 884 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4772      +/-   ##
==========================================
- Coverage   84.55%   84.45%   -0.11%     
==========================================
  Files        1117     1117              
  Lines      202644   202670      +26     
==========================================
- Hits       171353   171159     -194     
- Misses      31291    31511     +220     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread tests/cases/standalone/common/range/interval.result
Copy link
Copy Markdown
Contributor

@v0y4g3r v0y4g3r left a comment

Choose a reason for hiding this comment

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

Rest LGTM

Comment thread src/common/function/src/scalars/date/date_add.rs
Comment thread src/common/time/src/interval.rs
use crate::value::{Value, ValueRef};
use crate::vectors::{MutableVector, PrimitiveVector, PrimitiveVectorBuilder, Vector};

// TODO(yingwen): Can we remove `Into<serde_json::Value>`?
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.

Comment thread src/flow/src/repr.rs
Comment thread src/query/src/range_select/plan_rewrite.rs
@evenyag
Copy link
Copy Markdown
Contributor Author

evenyag commented Oct 10, 2024

I'm going to merge this if there are no further comments. @waynexia Are you going to check this PR?

@evenyag evenyag added this pull request to the merge queue Oct 14, 2024
Merged via the queue into main with commit 2f2b4b3 Oct 14, 2024
@evenyag evenyag deleted the reimpl-interval branch October 14, 2024 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change This pull request contains breaking changes. docs-not-required This change does not impact docs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants