-
Notifications
You must be signed in to change notification settings - Fork 333
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: allow nest range expr in Range Query #2557
feat: allow nest range expr in Range Query #2557
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #2557 +/- ##
===========================================
- Coverage 85.14% 84.83% -0.32%
===========================================
Files 738 738
Lines 118319 118955 +636
===========================================
+ Hits 100747 100919 +172
- Misses 17572 18036 +464 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a great job! I have some comments, please take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I hereby agree to the terms of the GreptimeDB CLA
What's changed and what's your intention?
Nest expr
A range expression like
max(a+1) Range '5m' FILL NULL
can be nested behind any expression, but the expression must contain at least one aggregate function.The following SQL is valid and is semantically equivalent to the following subquery
But nest range query (e.g.
SELECT min(max(val) RANGE '20s') RANGE '20s' FROM host ALIGN '10s';
) is invalid.Change rewrite format
Change the rewrite format to
range_fn(func, range, fill, byc, [byv], align)
. Letfunc
be parsed by datafusion to correctly deduce the type of range expression.FILL Support
Now
fill
Option is available in range query, We usefill
to fill the value that is null after the range query.Valid Fill Option are:
NULL
(default fill option): No operation is performed, null values will be displayed as originalPREV
: The previous value after the null value which is sorted by the timeline will be used to fill the null valueLINEAR
: The average of the two values before and after the null value which is sorted by the timeline will be used to fill the null value.x
: Any constant of the same type as the null value. All null values will be filled with this value.If you use the
LINEAR
strategy to fill an integer variable, the variable type will be implicitly converted to a floating point type.Checklist
Refer to a related PR or issue link (optional)
GreptimeTeam/sqlparser-rs#6
#1662