All function pipeline elements
This table lists all function pipeline elements in alphabetical order:
| Element | Category | Output |
|---|---|---|
abs() | Unary Mathematical | timevector pipeline |
add(val DOUBLE PRECISION) | Binary Mathematical | timevector pipeline |
average() | Aggregate Finalizer | DOUBLE PRECISION |
cbrt() | Unary Mathematical | timevector pipeline |
ceil() | Unary Mathematical | timevector pipeline |
counter_agg() | Aggregate Finalizer | CounterAgg |
delta() | Compound | timevector pipeline |
div | Binary Mathematical | timevector pipeline |
fill_to | Compound | timevector pipeline |
filter | Lambda | timevector pipeline |
floor | Unary Mathematical | timevector pipeline |
hyperloglog | Aggregate Finalizer | HyperLogLog |
ln | Unary Mathematical | timevector pipeline |
log10 | Unary Mathematical | timevector pipeline |
logn | Binary Mathematical | timevector pipeline |
lttb | Compound | timevector pipeline |
map | Lambda | timevector pipeline |
materialize | Output | timevector pipeline |
mod | Binary Mathematical | timevector pipeline |
mul | Binary Mathematical | timevector pipeline |
num_vals | Aggregate Finalizer | BIGINT |
power | Binary Mathematical | timevector pipeline |
round | Unary Mathematical | timevector pipeline |
sign | Unary Mathematical | timevector pipeline |
sort | Compound | timevector pipeline |
sqrt | Unary Mathematical | timevector pipeline |
stats_agg | Aggregate Finalizer | StatsSummary1D |
sub | Binary Mathematical | timevector pipeline |
sum | Aggregate Finalizer | timevector pipeline |
trunc | Unary Mathematical | timevector pipeline |
unnest | Output | TABLE (time TIMESTAMPTZ, value DOUBLE PRECISION) |
===== PAGE: https://docs.tigerdata.com/use-timescale/hyperfunctions/time-weighted-averages/ =====
Examples:
Example 1 (sql):
sql
SELECT device id,
sum(abs_delta) as volatility
FROM (
SELECT device_id,
abs(val - lag(val) OVER last_day) as abs_delta
FROM measurements
WHERE ts >= now()-'1 day'::interval) calc_delta
GROUP BY device_id;Example 2 (sql):
sql
SELECT device_id,
toolkit_experimental.timevector(ts, val)
-> toolkit_experimental.sort()
-> toolkit_experimental.delta()
-> toolkit_experimental.abs()
-> toolkit_experimental.sum() as volatility
FROM measurements
WHERE ts >= now()-'1 day'::interval
GROUP BY device_id;Example 3 (sql):
sql
SELECT device_id,
toolkit_experimental.timevector(ts, val)
FROM measurements
WHERE ts >= now() - '1 day'::interval
GROUP BY device_id;Example 4 (sql):
sql
SELECT device_id,
toolkit_experimental.timevector(ts, val)
-> toolkit_experimental.sort()
-> toolkit_experimental.delta()
-> toolkit_experimental.abs()
-> toolkit_experimental.sum() as volatility
FROM measurements
WHERE ts >= now() - '1 day'::interval
GROUP BY device_id;