Add ORDER BY to multi_subquery_in_where_clause

pull/2678/head
Onder Kalaci 2019-04-23 11:46:00 +03:00
parent 41f98f9c02
commit 913ffc9dcd
2 changed files with 5 additions and 6 deletions

View File

@ -612,7 +612,7 @@ WHERE
);
ERROR: cannot push down this subquery
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 subqueries even if they appear
-- in WHERE subquery -> FROM subquery -> WHERE subquery
-- but we can recursively plan that anyway
SELECT DISTINCT user_id
@ -636,15 +636,14 @@ WHERE user_id
users_table u1, events_table e1
WHERE
e1.user_id = u1.user_id
AND e1.user_id IN (SELECT user_id FROM users_table LIMIT 3 )
AND e1.user_id IN (SELECT user_id FROM users_table ORDER BY user_id LIMIT 3)
) as f_outer
WHERE f_inner.user_id = f_outer.user_id
) ORDER BY 1 LIMIT 3;
user_id
---------
1
5
(2 rows)
(1 row)
-- semi join is not on the partition key for the third subquery, and recursively planned
SET client_min_messages TO DEBUG1;

View File

@ -518,7 +518,7 @@ WHERE
OFFSET 3
);
-- we can detect unsupported subquerues even if they appear
-- we can detect unsupported subqueries even if they appear
-- in WHERE subquery -> FROM subquery -> WHERE subquery
-- but we can recursively plan that anyway
SELECT DISTINCT user_id
@ -542,7 +542,7 @@ WHERE user_id
users_table u1, events_table e1
WHERE
e1.user_id = u1.user_id
AND e1.user_id IN (SELECT user_id FROM users_table LIMIT 3 )
AND e1.user_id IN (SELECT user_id FROM users_table ORDER BY user_id LIMIT 3)
) as f_outer
WHERE f_inner.user_id = f_outer.user_id
) ORDER BY 1 LIMIT 3;