citusdata / citusdata/postgresql-topn
Aggregation error over a citus distributed table
- Dominant language
- C
- Stars
- 249
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
I have encountered with an error when I execute a query stated in TopN Readme page, over a citus distributed table. The same query worked when I used a reference or a local table instead of distributed one.
**postgres version**: pg14
**Citus repo**: citus-enterprise
**Branch**: release-11.0 (bea69bce45b1621bf4e27d2559e9e2b9755e3771)
**TopN branch**: master (865c82771e667cb98aa914ae9f5a2226218d1cd4)
#### Reproducing steps:
1. Created a cluster of 2 worker nodes using citus dev tool:
```bash
citus_dev make --destroy testCluster
```
2. Connect to the coordinator node.
```bash
pgsql -p 9700
```
3. Execute the commands in below.
```sql
CREATE EXTENSION topn;
CREATE TABLE customer_reviews
(
customer_id TEXT,
review_date DATE,
review_rating INTEGER,
review_votes INTEGER,
review_helpful_votes INTEGER,
product_id CHAR(10),
product_title TEXT,
product_sales_rank BIGINT,
product_group TEXT,
product_category TEXT,
product_subcategory TEXT,
similar_product_ids CHAR(10)[]
);
\COPY customer_reviews FROM 'customer_reviews_2000.csv' WITH CSV;
CREATE TABLE popular_products
(
review_date date UNIQUE,
agg_data jsonb
);
SELECT create_distributed_table('popular_products', 'review_date');
INSERT INTO popular_products
SELECT review_date, topn_add_agg(product_id)
FROM customer_reviews
GROUP BY review_date;
SELECT review_date, (topn(agg_data, 1)).*
FROM popular_products
ORDER BY review_date;
SELECT (topn(topn_union_agg(agg_data), 10)).*
FROM popular_products
WHERE review_date >= '2000-01-01' AND review_date < '2000-02-01'
ORDER BY 2 DESC;
```
#### Error:
```sql
ERROR: set-valued function called in context that cannot accept a set
LINE 1: SELECT (topn(topn_union_agg(agg_data), 10)).*
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.