https://github.com/phstudy/postgresql-datasketches
DataSketches functions for PostgreSQL
https://github.com/phstudy/postgresql-datasketches
datasketches postgresql
Last synced: about 1 month ago
JSON representation
DataSketches functions for PostgreSQL
- Host: GitHub
- URL: https://github.com/phstudy/postgresql-datasketches
- Owner: phstudy
- Created: 2020-07-02T10:11:01.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-14T02:54:29.000Z (almost 5 years ago)
- Last Synced: 2025-01-21T02:41:37.183Z (3 months ago)
- Topics: datasketches, postgresql
- Language: Dockerfile
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PostgreSQL-DataSketches
PostgreSQL-DataSketches brings [DataSketches functions](https://datasketches.apache.org/) to PostgreSQL via [PostgreSQL Adaptor for C++ DataSketches](https://github.com/apache/incubator-datasketches-postgresql).## Run in [Docker](https://hub.docker.com/r/study/postgresql-datasketches)
```bash
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d study/postgresql-datasketches
```## Test DataSketches functions in Docker
### Example
```bash
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d study/postgresql-datasketchesdocker exec -it some-postgres psql -U postgres
postgres=# SELECT cpc_sketch_get_estimate(cpc_sketch_union(respondents_sketch)) AS num_respondents, flavor
FROM (
SELECT
cpc_sketch_build(respondent) AS respondents_sketch,
flavor,
country
FROM (
SELECT * FROM (
VALUES (1, 'Vanilla', 'CH'),
(1, 'Chocolate', 'CH'),
(2, 'Chocolate', 'US'),
(2, 'Strawberry', 'US')) AS t(respondent, flavor, country)) as foo
GROUP BY flavor, country) as bar
GROUP BY flavor;
```### Result
```
num_respondents | flavor
-----------------+------------
1 | Strawberry
1 | Vanilla
2.00016277723359 | Chocolate
(3 rows)
```