mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-09-13 00:42:14 +00:00
* feat(function): add Welford stddev functions Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> * test(function): cover merged Welford time windows Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> * refactor(function): use stddev_pop SQL names Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> * fix(function): make Welford arithmetic partition-stable Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> * fix(function): reject invalid singleton Welford states Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> * test(function): pin Welford state compatibility Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> * refactor(function): remove unreachable variance clamp Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> * fix(function): reject DISTINCT Welford aggregates Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> * test(compat): bound Welford downgrade targets Signed-off-by: Lei, HUANG <ratuthomm@gmail.com> --------- Signed-off-by: Lei, HUANG <ratuthomm@gmail.com>
22 lines
508 B
Plaintext
22 lines
508 B
Plaintext
-- Direct calculation from each state persisted by the old binary.
|
|
SELECT grp, stddev_pop_calc(state) AS stddev
|
|
FROM stddev_states
|
|
ORDER BY grp;
|
|
|
|
+-----+--------+
|
|
| grp | stddev |
|
|
+-----+--------+
|
|
| 0 | 0.5 |
|
|
| 1 | 0.5 |
|
|
+-----+--------+
|
|
|
|
-- Merge all persisted states with the new binary before calculating.
|
|
SELECT stddev_pop_calc(stddev_pop_merge(state)) AS stddev
|
|
FROM stddev_states;
|
|
|
|
+-------------------+
|
|
| stddev |
|
|
+-------------------+
|
|
| 1.118033988749895 |
|
|
+-------------------+
|