From ddcf417a3737138585d4cecd15d0768a93292eb4 Mon Sep 17 00:00:00 2001 From: Thomas Hatzopoulos Date: Tue, 28 Mar 2023 15:32:52 -0500 Subject: [PATCH] stabilizing approx_count_distinct --- Changelog.md | 3 +++ extension/src/hyperloglog.rs | 12 ++++++------ extension/src/stabilization_info.rs | 4 ++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 03437192..a3c9cdbd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -12,6 +12,9 @@ This changelog should be updated as part of a PR if the work is worth noting (mo - [#733](https://github.com/timescale/timescaledb-toolkit/pull/733): Fix a bug when rolling up overlapping heartbeat_aggs - [#740](https://github.com/timescale/timescaledb-toolkit/pull/740): When interpolating an 'locf' time weighted average, extend last point to interpolation boundary +#### Stabilized features +- [#741](https://github.com/timescale/timescaledb-toolkit/pull/741): Stabilize `approx_count_distinct` + #### Other notable changes #### Shout-outs diff --git a/extension/src/hyperloglog.rs b/extension/src/hyperloglog.rs index 31d97f51..d3b08764 100644 --- a/extension/src/hyperloglog.rs +++ b/extension/src/hyperloglog.rs @@ -58,7 +58,7 @@ pub fn hyperloglog_trans( const APPROX_COUNT_DISTINCT_DEFAULT_SIZE: i32 = 32768; /// Similar to hyperloglog_trans(), except size is set to a default of 32,768 -#[pg_extern(immutable, parallel_safe, schema = "toolkit_experimental")] +#[pg_extern(immutable, parallel_safe)] pub fn approx_count_distinct_trans( state: Internal, // TODO we want to use crate::raw::AnyElement but it doesn't work for some reason... @@ -252,10 +252,10 @@ extension_sql!( extension_sql!( "\n\ - CREATE AGGREGATE toolkit_experimental.approx_count_distinct(value AnyElement)\n\ + CREATE AGGREGATE approx_count_distinct(value AnyElement)\n\ (\n\ stype = internal,\n\ - sfunc = toolkit_experimental.approx_count_distinct_trans,\n\ + sfunc = approx_count_distinct_trans,\n\ finalfunc = hyperloglog_final,\n\ combinefunc = hyperloglog_combine,\n\ serialfunc = hyperloglog_serialize,\n\ @@ -549,7 +549,7 @@ mod tests { let text = client .update( "SELECT \ - toolkit_experimental.approx_count_distinct(v::float)::TEXT \ + approx_count_distinct(v::float)::TEXT \ FROM generate_series(1, 100) v", None, None, @@ -595,9 +595,9 @@ mod tests { .update( "SELECT \ distinct_count(\ - toolkit_experimental.approx_count_distinct(v::float)\ + approx_count_distinct(v::float)\ ), \ - toolkit_experimental.approx_count_distinct(v::float) -> distinct_count() \ + approx_count_distinct(v::float) -> distinct_count() \ FROM generate_series(1, 100) v", None, None, diff --git a/extension/src/stabilization_info.rs b/extension/src/stabilization_info.rs index be03cb02..c2f9311f 100644 --- a/extension/src/stabilization_info.rs +++ b/extension/src/stabilization_info.rs @@ -11,6 +11,10 @@ crate::functions_stabilized_at! { STABLE_FUNCTIONS + "1.16.0" => { + approx_count_distinct(anyelement), + approx_count_distinct_trans(internal,anyelement), + } "1.15.0" => { arrow_counter_interpolated_delta(countersummary,counterinterpolateddeltaaccessor), arrow_counter_interpolated_rate(countersummary,counterinterpolatedrateaccessor),