8000 [columnar] Don't use vectorized aggregates if FILTER is used by mkaruza · Pull Request #181 · hydradatabase/columnar · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[columnar] Don't use vectorized aggregates if FILTER is used #181

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

Merged
merged 1 commit into from
Oct 25, 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
5 changes: 5 additions & 0 deletions columnar/src/backend/columnar/columnar_planner_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ ExpressionMutator(Node *node, void *context)
elog(ERROR, "Vectorized aggregate with DISTINCT not supported.");
}

if (oldAggRefNode->aggfilter)
{
elog(ERROR, "Vectorized aggregate with FILTER not supported");
}

newAggRefNode->args = (List *)
expression_tree_mutator((Node *) oldAggRefNode->args, AggRefArgsExpressionMutator, NULL);

Expand Down
26 changes: 26 additions & 0 deletions columnar/src/test/regress/expected/columnar_aggregates.out
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,30 @@ DETAIL: Vectorized Aggregates accepts accepts only valid column argument
(5 rows)

DROP TABLE t_mixed;
-- github#180
-- Vectorized aggregate does't accept filter on columns
CREATE TABLE t_filter(a INT) USING columnar;
INSERT INTO t_filter SELECT g FROM GENERATE_SERIES(0,100) g;
DEBUG: Flushing Stripe of size 101
EXPLAIN (verbose, costs off, timing off, summary off) SELECT COUNT(a) FILTER (WHERE a > 90) FROM t_filter;
DEBUG: Query can't be vectorized. Falling back to original execution.
DETAIL: Vectorized aggregate with FILTER not supported
QUERY PLAN
-----------------------------------------------------
Aggregate
Output: count(a) FILTER (WHERE (a > 90))
-> Custom Scan (ColumnarScan) on public.t_filter
Output: a
Columnar Projected Columns: a
(5 rows)

SELECT COUNT(a) FILTER (WHERE a > 90) FROM t_filter;
DEBUG: Query can't be vectorized. Falling back to original execution.
DETAIL: Vectorized aggregate with FILTER not supported
count
-------
10
(1 row)

DROP TABLE t_filter;
SET client_min_messages TO default;
22 changes: 22 additions & 0 deletions columnar/src/test/regress/expected/columnar_aggregates_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,26 @@ EXPLAIN (verbose, costs off, timing off, summary off) SELECT SUM(length(b::text)
(5 rows)

DROP TABLE t_mixed;
-- github#180
-- Vectorized aggregate does't accept filter on columns
CREATE TABLE t_filter(a INT) USING columnar;
INSERT INTO t_filter SELECT g FROM GENERATE_SERIES(0,100) g;
DEBUG: Flushing Stripe of size 101
EXPLAIN (verbose, costs off, timing off, summary off) SELECT COUNT(a) FILTER (WHERE a > 90) FROM t_filter;
QUERY PLAN
-----------------------------------------------------
Aggregate
Output: count(a) FILTER (WHERE (a > 90))
-> Custom Scan (ColumnarScan) on public.t_filter
Output: a
Columnar Projected Columns: a
(5 rows)

SELECT COUNT(a) FILTER (WHERE a > 90) FROM t_filter;
count
-------
10
(1 row)

DROP TABLE t_filter;
SET client_min_messages TO default;
13 changes: 13 additions & 0 deletions columnar/src/test/regress/sql/columnar_aggregates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,17 @@ EXPLAIN (verbose, costs off, timing off, summary off) SELECT SUM(length(b::text)

DROP TABLE t_mixed;

-- github#180
-- Vectorized aggregate does't accept filter on columns

CREATE TABLE t_filter(a INT) USING columnar;

INSERT INTO t_filter SELECT g FROM GENERATE_SERIES(0,100) g;

EXPLAIN (verbose, costs off, timing off, summary off) SELECT COUNT(a) FILTER (WHERE a > 90) FROM t_filter;

SELECT COUNT(a) FILTER (WHERE a > 90) FROM t_filter;

DROP TABLE t_filter;

SET client_min_messages TO default;
0