Skip to content

Commit bc6949c

Browse files
committed
Refactor subquery syntax in tests for clarity and consistency
1 parent 84fc680 commit bc6949c

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

src/test/regress/expected/subquery_in_where.out

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -735,23 +735,13 @@ WHERE
735735
-- make the clause recurring
736736
CREATE TABLE local_table(id int, value_1 int);
737737
INSERT INTO local_table VALUES(1,1), (2,2);
738-
SELECT
739-
*
740-
FROM
741-
(SELECT
742-
*
743-
FROM
744-
local_table) as sub_table
745-
WHERE
746-
id
747-
IN
748-
(SELECT
749-
user_id
750-
FROM
751-
users_table);
738+
SELECT s.*
739+
FROM (SELECT * FROM local_table) AS s
740+
WHERE s.id IN (SELECT u.user_id FROM users_table u)
741+
ORDER BY s.id;
752742
DEBUG: generating subplan XXX_1 for subquery SELECT id, value_1 FROM subquery_in_where.local_table
753-
DEBUG: generating subplan XXX_2 for subquery SELECT user_id FROM public.users_table
754-
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT id, value_1 FROM (SELECT intermediate_result.id, intermediate_result.value_1 FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(id integer, value_1 integer)) sub_table WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.user_id FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer)))
743+
DEBUG: generating subplan XXX_2 for subquery SELECT user_id FROM public.users_table u
744+
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT id, value_1 FROM (SELECT intermediate_result.id, intermediate_result.value_1 FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(id integer, value_1 integer)) s WHERE (id OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.user_id FROM read_intermediate_result('XXX_2'::text, 'binary'::citus_copy_format) intermediate_result(user_id integer))) ORDER BY id
755745
id | value_1
756746
---------------------------------------------------------------------
757747
1 | 1

src/test/regress/sql/subquery_in_where.sql

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -542,20 +542,10 @@ WHERE
542542
CREATE TABLE local_table(id int, value_1 int);
543543
INSERT INTO local_table VALUES(1,1), (2,2);
544544

545-
SELECT
546-
*
547-
FROM
548-
(SELECT
549-
*
550-
FROM
551-
local_table) as sub_table
552-
WHERE
553-
id
554-
IN
555-
(SELECT
556-
user_id
557-
FROM
558-
users_table);
545+
SELECT s.*
546+
FROM (SELECT * FROM local_table) AS s
547+
WHERE s.id IN (SELECT u.user_id FROM users_table u)
548+
ORDER BY s.id;
559549

560550
-- Use local table in WHERE clause
561551
SELECT

0 commit comments

Comments
 (0)