unsupported subquery error messages are fixed

pull/1901/head
mehmet furkan şahin 2017-12-22 11:40:45 +03:00
parent dcafd1368b
commit 446893234a
6 changed files with 98 additions and 13 deletions

View File

@ -960,14 +960,16 @@ DeferErrorIfCannotPushdownSubquery(Query *subqueryTree, bool outerMostQueryHasLi
if (subqueryTree->limitOffset) if (subqueryTree->limitOffset)
{ {
preconditionsSatisfied = false; preconditionsSatisfied = false;
errorDetail = "Offset clause is currently unsupported"; errorDetail = "Offset clause is currently unsupported when a subquery "
"references a column from another query";
} }
/* limit is not supported when SubqueryPushdown is not set */ /* limit is not supported when SubqueryPushdown is not set */
if (subqueryTree->limitCount && !SubqueryPushdown) if (subqueryTree->limitCount && !SubqueryPushdown)
{ {
preconditionsSatisfied = false; preconditionsSatisfied = false;
errorDetail = "Limit in subquery is currently unsupported"; errorDetail = "Limit in subquery is currently unsupported when a "
"subquery references a column from another query";
} }
/* /*
@ -1022,7 +1024,8 @@ DeferErrorIfCannotPushdownSubquery(Query *subqueryTree, bool outerMostQueryHasLi
{ {
preconditionsSatisfied = false; preconditionsSatisfied = false;
errorDetail = "Group by list without partition column is currently " errorDetail = "Group by list without partition column is currently "
"unsupported"; "unsupported when a subquery references a column "
"from another query";
} }
} }
@ -1041,7 +1044,8 @@ DeferErrorIfCannotPushdownSubquery(Query *subqueryTree, bool outerMostQueryHasLi
if (subqueryTree->hasAggs && (subqueryTree->groupClause == NULL)) if (subqueryTree->hasAggs && (subqueryTree->groupClause == NULL))
{ {
preconditionsSatisfied = false; preconditionsSatisfied = false;
errorDetail = "Aggregates without group by are currently unsupported"; errorDetail = "Aggregates without group by are currently unsupported "
"when a subquery references a column from another query";
} }
/* having clause without group by on partition column is not supported */ /* having clause without group by on partition column is not supported */
@ -1049,7 +1053,8 @@ DeferErrorIfCannotPushdownSubquery(Query *subqueryTree, bool outerMostQueryHasLi
{ {
preconditionsSatisfied = false; preconditionsSatisfied = false;
errorDetail = "Having qual without group by on partition column is " errorDetail = "Having qual without group by on partition column is "
"currently unsupported"; "currently unsupported when a subquery references "
"a column from another query";
} }
/* distinct clause list must include partition column */ /* distinct clause list must include partition column */

View File

@ -1213,7 +1213,7 @@ ORDER BY
user_id user_id
limit 50; limit 50;
ERROR: cannot push down this subquery ERROR: cannot push down this subquery
DETAIL: Limit in subquery is currently unsupported DETAIL: Limit in subquery is currently unsupported when a subquery references a column from another query
-- we recursively plan some queries but fail in the end -- we recursively plan some queries but fail in the end
-- since some_users_data since it has a reference -- since some_users_data since it has a reference
-- from an outer query which is not recursively planned -- from an outer query which is not recursively planned
@ -1250,7 +1250,7 @@ ORDER BY
user_id user_id
limit 50; limit 50;
ERROR: cannot push down this subquery ERROR: cannot push down this subquery
DETAIL: Limit in subquery is currently unsupported DETAIL: Limit in subquery is currently unsupported when a subquery references a column from another query
-- LATERAL JOINs used with INNER JOINs -- LATERAL JOINs used with INNER JOINs
SET citus.subquery_pushdown to ON; SET citus.subquery_pushdown to ON;
SELECT user_id, lastseen SELECT user_id, lastseen
@ -1598,7 +1598,7 @@ ORDER BY
user_id DESC user_id DESC
LIMIT 10; LIMIT 10;
ERROR: cannot push down this subquery ERROR: cannot push down this subquery
DETAIL: Limit in subquery is currently unsupported DETAIL: Limit in subquery is currently unsupported when a subquery references a column from another query
-- NESTED INNER JOINs -- NESTED INNER JOINs
SELECT SELECT
count(*) AS value, "generated_group_field" count(*) AS value, "generated_group_field"
@ -2200,7 +2200,7 @@ ORDER BY
value_2 DESC, user_id DESC value_2 DESC, user_id DESC
LIMIT 10; LIMIT 10;
ERROR: cannot push down this subquery ERROR: cannot push down this subquery
DETAIL: Limit in subquery is currently unsupported DETAIL: Limit in subquery is currently unsupported when a subquery references a column from another query
-- lets test some unsupported set operations -- lets test some unsupported set operations
-- not supported since we use INTERSECT -- not supported since we use INTERSECT
SELECT ("final_query"."event_types") as types, count(*) AS sumOfEventType SELECT ("final_query"."event_types") as types, count(*) AS sumOfEventType

View File

@ -610,7 +610,7 @@ WHERE
OFFSET 3 OFFSET 3
); );
ERROR: cannot push down this subquery ERROR: cannot push down this subquery
DETAIL: Offset clause is currently unsupported DETAIL: Offset clause is currently unsupported when a subquery references a column from another query
-- we can detect unsupported subquerues even if they appear -- we can detect unsupported subquerues even if they appear
-- in WHERE subquery -> FROM subquery -> WHERE subquery -- in WHERE subquery -> FROM subquery -> WHERE subquery
-- but we can recursively plan that anyway -- but we can recursively plan that anyway

View File

@ -493,7 +493,7 @@ HAVING count(*) > 3
ORDER BY user_id ORDER BY user_id
LIMIT 5; LIMIT 5;
ERROR: cannot push down this subquery ERROR: cannot push down this subquery
DETAIL: Group by list without partition column is currently unsupported DETAIL: Group by list without partition column is currently unsupported when a subquery references a column from another query
-- similar query with slightly more complex group by -- similar query with slightly more complex group by
-- though the error message is a bit confusing -- though the error message is a bit confusing
SELECT SELECT
@ -516,4 +516,4 @@ HAVING count(*) > 3
ORDER BY user_id ORDER BY user_id
LIMIT 5; LIMIT 5;
ERROR: cannot push down this subquery ERROR: cannot push down this subquery
DETAIL: Group by list without partition column is currently unsupported DETAIL: Group by list without partition column is currently unsupported when a subquery references a column from another query

View File

@ -143,6 +143,46 @@ DEBUG: generating subplan 17_1 for subquery SELECT users_table.value_2 FROM pub
DEBUG: Plan 17 query after replacing subqueries and CTEs: SELECT foo.value_2 FROM ((SELECT intermediate_result.value_2 FROM read_intermediate_result('17_1'::text, 'binary'::citus_copy_format) intermediate_result(value_2 integer)) foo LEFT JOIN (SELECT users_table.value_2 FROM public.users_table, public.events_table WHERE ((users_table.user_id = events_table.user_id) AND (events_table.event_type = ANY (ARRAY[5, 6, 7, 8])))) bar ON ((foo.value_2 = bar.value_2))) DEBUG: Plan 17 query after replacing subqueries and CTEs: SELECT foo.value_2 FROM ((SELECT intermediate_result.value_2 FROM read_intermediate_result('17_1'::text, 'binary'::citus_copy_format) intermediate_result(value_2 integer)) foo LEFT JOIN (SELECT users_table.value_2 FROM public.users_table, public.events_table WHERE ((users_table.user_id = events_table.user_id) AND (events_table.event_type = ANY (ARRAY[5, 6, 7, 8])))) bar ON ((foo.value_2 = bar.value_2)))
ERROR: cannot pushdown the subquery ERROR: cannot pushdown the subquery
DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join
-- Aggregates in subquery without partition column can be planned recursively
-- unless there is a reference to an outer query
SELECT
*
FROM
users_table
WHERE
user_id IN
(
SELECT
SUM(events_table.user_id)
FROM
events_table
WHERE
users_table.user_id = events_table.user_id
)
;
ERROR: cannot push down this subquery
DETAIL: Aggregates without group by are currently unsupported when a subquery references a column from another query
-- Having qual without group by on partition column can be planned recursively
-- unless there is a reference to an outer query
SELECT
*
FROM
users_table
WHERE
user_id IN
(
SELECT
SUM(events_table.user_id)
FROM
events_table
WHERE
events_table.user_id = users_table.user_id
HAVING
MIN(value_2) > 2
)
;
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
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

@ -131,7 +131,47 @@ FROM
(SELECT users_table.value_2 FROM users_table, events_table WHERE users_table.user_id = events_table.user_id AND event_type IN (5,6,7,8)) as bar (SELECT users_table.value_2 FROM users_table, events_table WHERE users_table.user_id = events_table.user_id AND event_type IN (5,6,7,8)) as bar
ON(foo.value_2 = bar.value_2); ON(foo.value_2 = bar.value_2);
-- Aggregates in subquery without partition column can be planned recursively
-- unless there is a reference to an outer query
SELECT
*
FROM
users_table
WHERE
user_id IN
(
SELECT
SUM(events_table.user_id)
FROM
events_table
WHERE
users_table.user_id = events_table.user_id
)
;
-- Having qual without group by on partition column can be planned recursively
-- unless there is a reference to an outer query
SELECT
*
FROM
users_table
WHERE
user_id IN
(
SELECT
SUM(events_table.user_id)
FROM
events_table
WHERE
events_table.user_id = users_table.user_id
HAVING
MIN(value_2) > 2
)
;
SET client_min_messages TO DEFAULT; SET client_min_messages TO DEFAULT;
DROP SCHEMA not_supported CASCADE; DROP SCHEMA not_supported CASCADE;
SET search_path TO public; SET search_path TO public;