Skip to content

Commit

Permalink
fix citusdata#7647 Add comment and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ольга Сергеева committed Feb 18, 2025
1 parent eab9463 commit d9609d9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/backend/columnar/columnar_customscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,10 @@ FindCandidateRelids(PlannerInfo *root, RelOptInfo *rel, List *joinClauses)
candidateRelids = bms_del_members(candidateRelids, rel->relids);
candidateRelids = bms_del_members(candidateRelids, rel->lateral_relids);

/*
* For the relevant PG16 commit requiring this addition:
* postgres/postgres@2489d76
*/
#if PG_VERSION_NUM >= PG_VERSION_16
candidateRelids = bms_del_members(candidateRelids, root->outer_join_rels);
#endif
Expand Down
27 changes: 27 additions & 0 deletions src/test/regress/expected/columnar_join.out
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,33 @@ ORDER BY 3,4,1,2;
3 | 30 | 6 | 60
(9 rows)

-- Left Join with Mixed Table Types and columnar in the middle
CREATE TABLE tbl_middle_left_heap1 (id integer);
CREATE TABLE tbl_middle_left_heap2 (id integer);
CREATE TABLE tbl_middle_left_columnar (id integer) USING columnar;
INSERT INTO tbl_middle_left_heap1 VALUES (1), (2), (3), (4);
INSERT INTO tbl_middle_left_heap2 VALUES (2), (3), (5), (6);
INSERT INTO tbl_middle_left_columnar VALUES (3), (5), (7);
EXPLAIN (COSTS OFF)
SELECT h1.*, h2.*, c.*
FROM tbl_middle_left_heap1 h1
LEFT JOIN tbl_middle_left_columnar c ON h1.id = c.id
LEFT JOIN tbl_middle_left_heap2 h2 ON c.id = h2.id
ORDER BY 1;
QUERY PLAN
---------------------------------------------------------------------
Sort
Sort Key: h1.id
-> Nested Loop Left Join
Join Filter: (c.id = h2.id)
-> Nested Loop Left Join
Join Filter: (h1.id = c.id)
-> Seq Scan on tbl_middle_left_heap1 h1
-> Custom Scan (ColumnarScan) on tbl_middle_left_columnar c
Columnar Projected Columns: id
-> Seq Scan on tbl_middle_left_heap2 h2
(10 rows)

-- End test case
SET client_min_messages TO warning;
DROP SCHEMA am_columnar_join CASCADE;
16 changes: 16 additions & 0 deletions src/test/regress/sql/columnar_join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ FROM tbl_cross_heap h
CROSS JOIN tbl_cross_columnar c
ORDER BY 3,4,1,2;

-- Left Join with Mixed Table Types and columnar in the middle
CREATE TABLE tbl_middle_left_heap1 (id integer);
CREATE TABLE tbl_middle_left_heap2 (id integer);
CREATE TABLE tbl_middle_left_columnar (id integer) USING columnar;

INSERT INTO tbl_middle_left_heap1 VALUES (1), (2), (3), (4);
INSERT INTO tbl_middle_left_heap2 VALUES (2), (3), (5), (6);
INSERT INTO tbl_middle_left_columnar VALUES (3), (5), (7);

EXPLAIN (COSTS OFF)
SELECT h1.*, h2.*, c.*
FROM tbl_middle_left_heap1 h1
LEFT JOIN tbl_middle_left_columnar c ON h1.id = c.id
LEFT JOIN tbl_middle_left_heap2 h2 ON c.id = h2.id
ORDER BY 1;

-- End test case
SET client_min_messages TO warning;
DROP SCHEMA am_columnar_join CASCADE;

0 comments on commit d9609d9

Please sign in to comment.