Merge pull request #2507 from citusdata/error_out_grouping_sets_in_subqueries

Error out when a subquery has grouping set clause
pull/2305/head
Hanefi Onaldi 2018-11-30 15:14:45 +03:00 committed by GitHub
commit a9c299473b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View File

@ -807,6 +807,14 @@ DeferErrorIfCannotPushdownSubquery(Query *subqueryTree, bool outerMostQueryHasLi
} }
} }
/* grouping sets are not allowed in subqueries*/
if (subqueryTree->groupingSets)
{
preconditionsSatisfied = false;
errorDetail = "could not run distributed query with GROUPING SETS, CUBE, "
"or ROLLUP";
}
/* /*
* We support window functions when the window function * We support window functions when the window function
* is partitioned on distribution column. * is partitioned on distribution column.

View File

@ -157,6 +157,17 @@ WHERE
; ;
ERROR: cannot push down this subquery ERROR: cannot push down this subquery
DETAIL: Having qual without group by on partition column is currently unsupported when a subquery references a column from another query DETAIL: Having qual without group by on partition column is currently unsupported when a subquery references a column from another query
-- We do not support GROUPING SETS in subqueries
-- This also includes ROLLUP or CUBE clauses
SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY GROUPING SETS ((user_id), (value_1))) s;
ERROR: could not run distributed query with GROUPING SETS, CUBE, or ROLLUP
HINT: Consider using an equality filter on the distributed table's partition column.
SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY ROLLUP (user_id, value_1)) s;
ERROR: could not run distributed query with GROUPING SETS, CUBE, or ROLLUP
HINT: Consider using an equality filter on the distributed table's partition column.
SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY CUBE (user_id, value_1)) s;
ERROR: could not run distributed query with GROUPING SETS, CUBE, or ROLLUP
HINT: Consider using an equality filter on the distributed table's partition column.
SET client_min_messages TO DEFAULT; SET client_min_messages TO DEFAULT;
DROP SCHEMA not_supported CASCADE; DROP SCHEMA not_supported CASCADE;
NOTICE: drop cascades to table users_table_local NOTICE: drop cascades to table users_table_local

View File

@ -149,6 +149,13 @@ WHERE
) )
; ;
-- We do not support GROUPING SETS in subqueries
-- This also includes ROLLUP or CUBE clauses
SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY GROUPING SETS ((user_id), (value_1))) s;
SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY ROLLUP (user_id, value_1)) s;
SELECT * FROM (SELECT user_id, value_1 FROM users_table GROUP BY CUBE (user_id, value_1)) s;
SET client_min_messages TO DEFAULT; SET client_min_messages TO DEFAULT;
DROP SCHEMA not_supported CASCADE; DROP SCHEMA not_supported CASCADE;