Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/backend/optimizer/plan/planshare.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ make_shareinputscan(PlannerInfo *root, Plan *inputplan)
sisc->scan.plan.plan_rows = inputplan->plan_rows;
sisc->scan.plan.plan_width = inputplan->plan_width;

sisc->scan.plan.locustype = inputplan->locustype;
sisc->scan.plan.parallel = 0; /* No parallel ShareInputScan */

return sisc;
}

Expand Down
54 changes: 53 additions & 1 deletion src/test/regress/expected/cbdb_parallel.out
Original file line number Diff line number Diff line change
Expand Up @@ -3516,7 +3516,59 @@ WHERE e.salary > (
David
(2 rows)


--
-- Test https://github.com/apache/cloudberry/issues/1376
--
create table t1(a int, b int);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Apache Cloudberry data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
create table t2 (like t1);
NOTICE: table doesn't have 'DISTRIBUTED BY' clause, defaulting to distribution columns from LIKE table
set gp_cte_sharing = on;
explain(locus, costs off) with x as
(select a, count(*) as b from t1 group by a union all
select a, count(*) as b from t2 group by a)
select count(*) from x a join x b on a.a = b.b;
QUERY PLAN
------------------------------------------------------------------------
Finalize Aggregate
Locus: Entry
-> Gather Motion 3:1 (slice1; segments: 3)
Locus: Entry
-> Partial Aggregate
Locus: Hashed
-> Hash Join
Locus: Hashed
Hash Cond: (b.b = a.a)
-> Redistribute Motion 3:3 (slice2; segments: 3)
Locus: Hashed
Hash Key: b.b
-> Subquery Scan on b
Locus: Strewn
-> Shared Scan (share slice:id 2:0)
Locus: Hashed
-> Hash
Locus: Hashed
-> Subquery Scan on a
Locus: Hashed
-> Shared Scan (share slice:id 1:0)
Locus: Hashed
-> Append
Locus: Hashed
-> HashAggregate
Locus: Hashed
Group Key: t1.a
-> Seq Scan on t1
Locus: Hashed
-> HashAggregate
Locus: Hashed
Group Key: t2.a
-> Seq Scan on t2
Locus: Hashed
Optimizer: Postgres query optimizer
(35 rows)

reset gp_cte_sharing;
reset enable_parallel;
reset min_parallel_table_scan_size;
-- start_ignore
Expand Down
15 changes: 14 additions & 1 deletion src/test/regress/sql/cbdb_parallel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,20 @@ WHERE e.salary > (
SELECT AVG(salary)
FROM employees
WHERE department_id = e.department_id);


--
-- Test https://github.com/apache/cloudberry/issues/1376
--
create table t1(a int, b int);
create table t2 (like t1);
set gp_cte_sharing = on;

explain(locus, costs off) with x as
(select a, count(*) as b from t1 group by a union all
select a, count(*) as b from t2 group by a)
select count(*) from x a join x b on a.a = b.b;

reset gp_cte_sharing;
reset enable_parallel;
reset min_parallel_table_scan_size;
Comment thread
yjhjstz marked this conversation as resolved.

Expand Down
Loading