Skip to content

Commit

Permalink
feat: Postgres Citus Data HLL plugin implementation (#601) Thanks to @…
Browse files Browse the repository at this point in the history
…milanbella !

* pg_approx_hll

* pg_approx_hll

* pg_approx_hll

Co-authored-by: milan.bella@ibm.com <milan.bella@ibm.com>

Fixes #563
  • Loading branch information
milanbella authored Apr 20, 2020
1 parent 6fbd703 commit be85ac6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/cubejs-schema-compiler/adapter/PostgresQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ class PostgresQuery extends BaseQuery {
timeGroupedColumn(granularity, dimension) {
return `date_trunc('${GRANULARITY_TO_INTERVAL[granularity]}', ${dimension})`;
}

hllInit(sql) {
return `hll_add_agg(hll_hash_any(${sql}))`;
}

hllMerge(sql) {
return `hll_cardinality(hll_union_agg(${sql}))`;
}

countDistinctApprox(sql) {
return `hll_cardinality(hll_add_agg(hll_hash_any(${sql})))`;
}
}

module.exports = PostgresQuery;

0 comments on commit be85ac6

Please sign in to comment.