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
Avoid having to cast time arg for cagg policy #2387
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2387 +/- ##
==========================================
+ Coverage 89.95% 90.10% +0.14%
==========================================
Files 213 213
Lines 34354 34326 -28
==========================================
+ Hits 30904 30928 +24
+ Misses 3450 3398 -52
Continue to review full report at Codecov.
|
static void | ||
check_valid_interval(Oid dim_type, Oid interval_type, const char *str_msg) | ||
static Datum | ||
convert_interval_arg(Oid dim_type, Datum interval, Oid *interval_type, const char *str_msg) |
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.
Isn't this conversion useful for other policies as well (e.g., retention)? I figured this would be in time_utils or policy_utils for use by all policies.
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.
Yes, I thought maybe to do that in another PR related to the retention policy.
4cfcb60
to
fb4974a
Compare
\set ON_ERROR_STOP 1 | ||
SELECT add_continuous_aggregate_policy('max_mat_view_date', '2 day'::interval, '1 day'::interval , '1 day'::interval) as job_id \gset | ||
SELECT add_continuous_aggregate_policy('max_mat_view_date', '2 day', '1 day', '1 day'::interval) as job_id \gset |
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.
Nit: Would be nice to get rid of the cast on schedule_interval too. Perhaps also for a separate PR?
SELECT add_continuous_aggregate_policy('max_mat_view_date', '2 day', '1 day', '1 day'::interval) as job_id \gset | |
SELECT add_continuous_aggregate_policy('max_mat_view_date', '2 days', '1 day', '1 day'::interval) as job_id \gset |
fb4974a
to
122853d
Compare
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
It might be useful to give short comment describing the function.
And I am not favour of reusing variable names, especially it is set to a different value.
@@ -41,6 +41,45 @@ subtract_interval_from_now(Oid timetype, const Interval *interval) | |||
return res; | |||
} | |||
|
|||
Datum |
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.
I think it is worth do document this function as it is part of internal API, so it is clear what to expect from it and how to use it. Currently I cannot guess from the function name what to expect from it.
{ | ||
case 1: | ||
/* Functions that take one input argument, e.g., the Date function */ | ||
arg = OidFunctionCall1(infuncid, arg); |
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.
Am I correct that this is a reuse of variable arg
, which first contains the original argument, and then assigned the converted argument? I suggest to use different variable and actually it will contain different object to my understanding.
} | ||
/* If no explicit cast was done by the user, try to convert the argument | ||
* to the time type used by the continuous aggregate. */ | ||
arg = ts_time_datum_convert_arg(arg, &argtype, timetype); |
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.
Same comment here, since arg
will contain different object after the call. To avoid code changes, the original variable can be called arg_in
.
ereport(ERROR, | ||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE), | ||
errmsg("invalid time argument"), | ||
errhint("Time argument requires an explicit cast."))); |
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.
Is it possible to test this case? Codecov complains that it's not covered.
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.
I think most of those cases already covered by continuous agg refresh function tests, which are reusing the same functionality.
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.
I guess Codecov would not complain if it is covered ;) I searched that such error is never expected in our tests.
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.
I don't think this case is actually possible right now, it was made more like a precaution in case new time functions will arrive in future versions I believe
122853d
to
b5615ca
Compare
This patch does a minor refactoring and adds a way to guess interval argument type based on used cagg Issue: timescale#2286
b5615ca
to
14448fb
Compare
This patch does a minor refactoring and adds a way to guess
interval argument type based on used cagg
Issue: #2286