Skip to content
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

Stabilizing approx_count_distinct #741

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions extension/src/hyperloglog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -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\
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions extension/src/stabilization_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down