Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add align to / interval support in range query #2842

Merged
merged 4 commits into from
Dec 4, 2023
Merged

feat: add align to / interval support in range query #2842

merged 4 commits into from
Dec 4, 2023

Conversation

Taylor-lagrange
Copy link
Contributor

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

Add align to / interval support in range query

Interval Support

The Interval expr can follow after RANGE and ALIGN keyword, as a optional replacement of duration string.

Must use parentheses in interval, otherwise it will cause syntax conflicts

Case like:

SELECT 
    rate(a) RANGE (INTERVAL '1 year 2 hours 3 minutes') 
FROM 
    t 
    ALIGN (INTERVAL '1 year 2 hours 3 minutes')
FILL NULL;

ALIGN TO support

Support ALIGN TO sub clause, user cam use ALIGN TO to align to the time they want

SELECT rate(a) RANGE '6m' FROM t ALIGN '1h' TO '2021-07-01 00:00:00' by (a, b) FILL NULL;

available ALIGN TO Option are:

  • Calendar (default): align to UTC timestamp 0
  • Now: align to current UTC timestamp
  • Timestamp: align to specific timestamp user assign

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.

Refer to a related PR or issue link (optional)

GreptimeTeam/sqlparser-rs#9

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Merging #2842 (d6fff79) into develop (445bd92) will decrease coverage by 0.41%.
Report is 7 commits behind head on develop.
The diff coverage is 83.13%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2842      +/-   ##
===========================================
- Coverage    84.80%   84.39%   -0.41%     
===========================================
  Files          734      737       +3     
  Lines       115181   115871     +690     
===========================================
+ Hits         97679    97791     +112     
- Misses       17502    18080     +578     

Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

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

Almost LGTM

src/query/src/range_select/plan.rs Outdated Show resolved Hide resolved
src/query/src/range_select/plan.rs Outdated Show resolved Hide resolved
@waynexia waynexia added this pull request to the merge queue Dec 4, 2023
Merged via the queue into GreptimeTeam:develop with commit 806400c Dec 4, 2023
13 checks passed
@Taylor-lagrange Taylor-lagrange deleted the feat-range-align branch December 5, 2023 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants