Skip to content

Aggregation error over a citus distributed table #53

@aykut-bozkurt

Description

@aykut-bozkurt

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 (865c827)

Reproducing steps:

  1. Created a cluster of 2 worker nodes using citus dev tool:
citus_dev make --destroy testCluster
  1. Connect to the coordinator node.
pgsql -p 9700
  1. Execute the commands in below.
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:

ERROR:  set-valued function called in context that cannot accept a set
LINE 1: SELECT (topn(topn_union_agg(agg_data), 10)).*

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions