Skip to content

Commit fd834d4

Browse files
committed
renamed interval to duration, formatted extension_sql! blocks
1 parent 8c110e2 commit fd834d4

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

extension/src/counter_agg.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,13 @@ fn counter_agg_extrapolated_delta<'a>(summary: CounterSummary<'a>, method: &str)
622622
// Public facing interpolated_delta
623623
extension_sql!(
624624
"\n\
625-
CREATE FUNCTION toolkit_experimental.interpolated_delta(summary countersummary, start timestamptz, intervalparam interval, prev countersummary, next countersummary) RETURNS double precision AS $$\n\
626-
SELECT interpolated_delta(summary,start,intervalparam,prev,next)\n\
627-
$$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;\n\
625+
CREATE FUNCTION toolkit_experimental.interpolated_delta(summary countersummary,\n\
626+
start timestamptz,\n\
627+
duration interval,\n\
628+
prev countersummary,\n\
629+
next countersummary) RETURNS DOUBLE PRECISION\n\
630+
AS $$\n\
631+
SELECT interpolated_delta(summary,start,duration,prev,next) $$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;\n\
628632
",
629633
name = "experimental_interpolated_delta", requires=[counter_agg_interpolated_delta]
630634
);
@@ -633,11 +637,11 @@ $$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;\n\
633637
fn counter_agg_interpolated_delta<'a>(
634638
summary: CounterSummary<'a>,
635639
start: crate::raw::TimestampTz,
636-
intervalparam: crate::raw::Interval,
640+
duration: crate::raw::Interval,
637641
prev: Option<CounterSummary<'a>>,
638642
next: Option<CounterSummary<'a>>,
639643
) -> f64 {
640-
let interval = crate::datum_utils::interval_to_ms(&start, &intervalparam);
644+
let interval = crate::datum_utils::interval_to_ms(&start, &duration);
641645
summary
642646
.interpolate(start.into(), interval, prev, next)
643647
.to_internal_counter_summary()
@@ -667,22 +671,27 @@ fn counter_agg_extrapolated_rate<'a>(summary: CounterSummary<'a>, method: &str)
667671
// Public facing interpolated_rate
668672
extension_sql!(
669673
"\n\
670-
CREATE FUNCTION toolkit_experimental.interpolated_rate(summary countersummary, start timestamptz, intervalparam interval, prev countersummary, next countersummary) RETURNS double precision AS $$\n\
671-
SELECT interpolated_rate(summary,start,intervalparam,prev,next)\n\
672-
$$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;\n\
674+
CREATE FUNCTION toolkit_experimental.interpolated_rate(summary countersummary,\n\
675+
start timestamptz,\n\
676+
duration interval,\n\
677+
prev countersummary,\n\
678+
next countersummary) RETURNS DOUBLE PRECISION\n\
679+
AS $$\n\
680+
SELECT interpolated_rate(summary,start,duration,prev,next) $$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;\n\
673681
",
674-
name = "experimental_interpolated_rate", requires=[counter_agg_interpolated_rate]
682+
name = "experimental_interpolated_rate",
683+
requires = [counter_agg_interpolated_rate]
675684
);
676685

677686
#[pg_extern(name = "interpolated_rate", immutable, parallel_safe)]
678687
fn counter_agg_interpolated_rate<'a>(
679688
summary: CounterSummary<'a>,
680689
start: crate::raw::TimestampTz,
681-
intervalparam: crate::raw::Interval,
690+
duration: crate::raw::Interval,
682691
prev: Option<CounterSummary<'a>>,
683692
next: Option<CounterSummary<'a>>,
684693
) -> Option<f64> {
685-
let interval = crate::datum_utils::interval_to_ms(&start, &intervalparam);
694+
let interval = crate::datum_utils::interval_to_ms(&start, &duration);
686695
summary
687696
.interpolate(start.into(), interval, prev, next)
688697
.to_internal_counter_summary()

extension/src/stabilization_info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
crate::functions_stabilized_at! {
1313
STABLE_FUNCTIONS
14-
"1.13.0" => {
15-
interpolated_average(timeweightsummary,timestamp with time zone,interval,timeweightsummary,timeweightsummary),
16-
interpolated_delta(countersummary,timestamp with time zone,interval,countersummary,countersummary),
17-
interpolated_rate(countersummary,timestamp with time zone,interval,countersummary,countersummary),
14+
"1.14.0" => {
15+
interpolated_average(timeweightsummary,timestamp with time zone,interval,timeweightsummary,timeweightsummary),
16+
interpolated_delta(countersummary,timestamp with time zone,interval,countersummary,countersummary),
17+
interpolated_rate(countersummary,timestamp with time zone,interval,countersummary,countersummary),
1818
}
1919
"1.12.0" => {
2020
stats1d_tf_inv_trans(internal,double precision),

extension/src/time_weighted_average.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,14 @@ pub fn time_weighted_average_integral<'a>(
475475
fn interpolate<'a>(
476476
tws: Option<TimeWeightSummary>,
477477
start: crate::raw::TimestampTz,
478-
interval: crate::raw::Interval,
478+
duration: crate::raw::Interval,
479479
prev: Option<TimeWeightSummary>,
480480
next: Option<TimeWeightSummary>,
481481
) -> Option<TimeWeightSummary<'a>> {
482482
match tws {
483483
None => None,
484484
Some(tws) => {
485-
let interval = crate::datum_utils::interval_to_ms(&start, &interval);
485+
let interval = crate::datum_utils::interval_to_ms(&start, &duration);
486486
Some(tws.interpolate(start.into(), interval, prev, next))
487487
}
488488
}
@@ -491,9 +491,13 @@ fn interpolate<'a>(
491491
// Public facing interpolated_average
492492
extension_sql!(
493493
"\n\
494-
CREATE FUNCTION toolkit_experimental.interpolated_average(tws timeweightsummary, start timestamptz, intervalparam interval, prev timeweightsummary, next timeweightsummary) RETURNS double precision AS $$\n\
495-
SELECT interpolated_average(tws,start,intervalparam,prev,next)\n\
496-
$$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;\n\
494+
CREATE FUNCTION toolkit_experimental.interpolated_average(tws timeweightsummary,\n\
495+
start timestamptz,\n\
496+
duration interval,\n\
497+
prev timeweightsummary,\n\
498+
next timeweightsummary) RETURNS DOUBLE PRECISION\n\
499+
AS $$\n\
500+
SELECT interpolated_average(tws,start,duration,prev,next) $$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;\n\
497501
",
498502
name = "experimental_interpolated_average", requires = [time_weighted_average_interpolated_average]
499503
);
@@ -502,11 +506,11 @@ $$ LANGUAGE SQL IMMUTABLE PARALLEL SAFE;\n\
502506
pub fn time_weighted_average_interpolated_average<'a>(
503507
tws: Option<TimeWeightSummary<'a>>,
504508
start: crate::raw::TimestampTz,
505-
intervalparam: crate::raw::Interval,
509+
duration: crate::raw::Interval,
506510
prev: Option<TimeWeightSummary<'a>>,
507511
next: Option<TimeWeightSummary<'a>>,
508512
) -> Option<f64> {
509-
let target = interpolate(tws, start, intervalparam, prev, next);
513+
let target = interpolate(tws, start, duration, prev, next);
510514
time_weighted_average_average(target)
511515
}
512516

0 commit comments

Comments
 (0)