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: 2 additions & 1 deletion src/backend/cdb/cdbsetop.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ choose_setop_type(List *pathlist, List *tlist_list)
break;

case CdbLocusType_Replicated:
ok_partitioned = false;
break;

case CdbLocusType_ReplicatedWorkers:
Expand Down Expand Up @@ -231,6 +232,7 @@ adjust_setop_arguments(PlannerInfo *root, List *pathlist, List *tlist_list, GpSe
case CdbLocusType_HashedWorkers:
case CdbLocusType_HashedOJ:
case CdbLocusType_Strewn:
case CdbLocusType_Replicated:
/* Gather to QE. No need to keep ordering. */
CdbPathLocus_MakeSingleQE(&locus, getgpsegmentCount());
adjusted_path = cdbpath_create_motion_path(root, subpath, NULL, false,
Expand All @@ -254,7 +256,6 @@ adjust_setop_arguments(PlannerInfo *root, List *pathlist, List *tlist_list, GpSe

case CdbLocusType_Entry:
case CdbLocusType_Null:
case CdbLocusType_Replicated:
case CdbLocusType_ReplicatedWorkers:
case CdbLocusType_End:
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
Expand Down
32 changes: 32 additions & 0 deletions src/test/regress/expected/union_gp.out
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,38 @@ select json_data,id from my_table where json_data->>'age' = '30' union all sele
set optimizer_parallel_union to off;
drop table if exists my_table;
--
-- test Github issue https://github.com/apache/cloudberry/issues/1240
--
create table r_1240(a int) distributed replicated;
insert into r_1240 select generate_series(1,10);
create table p1_1240(a int) distributed by (a);
insert into p1_1240 select generate_series(1,3);
explain(costs off) with result as (update r_1240 set a = a +1 where a < 5 returning *) select * from result except select * from p1_1240;
QUERY PLAN
---------------------------------------------------------------
HashSetOp Except
-> Append
-> Explicit Gather Motion 3:1 (slice1; segments: 3)
-> Subquery Scan on "*SELECT* 1"
-> Update on r_1240
-> Seq Scan on r_1240
Filter: (a < 5)
-> Gather Motion 3:1 (slice2; segments: 3)
-> Subquery Scan on "*SELECT* 2"
-> Seq Scan on p1_1240
Optimizer: Postgres-based planner
(11 rows)

with result as (update r_1240 set a = a +1 where a < 5 returning *) select * from result except select * from p1_1240;
a
---
5
4
(2 rows)

drop table r_1240;
drop table p1_1240;
--
-- Clean up
--
DROP TABLE IF EXISTS T_a1 CASCADE;
Expand Down
36 changes: 36 additions & 0 deletions src/test/regress/expected/union_gp_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -2439,6 +2439,42 @@ select json_data,id from my_table where json_data->>'age' = '30' union all sele
set optimizer_parallel_union to off;
drop table if exists my_table;
--
-- test Github issue https://github.com/apache/cloudberry/issues/1240
--
create table r_1240(a int) distributed replicated;
insert into r_1240 select generate_series(1,10);
create table p1_1240(a int) distributed by (a);
insert into p1_1240 select generate_series(1,3);
explain(costs off) with result as (update r_1240 set a = a +1 where a < 5 returning *) select * from result except select * from p1_1240;
INFO: GPORCA failed to produce a plan, falling back to Postgres-based planner
DETAIL: Falling back to Postgres-based planner because GPORCA does not support the following feature: RETURNING clause
QUERY PLAN
---------------------------------------------------------------
HashSetOp Except
-> Append
-> Explicit Gather Motion 3:1 (slice1; segments: 3)
-> Subquery Scan on "*SELECT* 1"
-> Update on r_1240
-> Seq Scan on r_1240
Filter: (a < 5)
-> Gather Motion 3:1 (slice2; segments: 3)
-> Subquery Scan on "*SELECT* 2"
-> Seq Scan on p1_1240
Optimizer: Postgres-based planner
(11 rows)

with result as (update r_1240 set a = a +1 where a < 5 returning *) select * from result except select * from p1_1240;
INFO: GPORCA failed to produce a plan, falling back to Postgres-based planner
DETAIL: Falling back to Postgres-based planner because GPORCA does not support the following feature: RETURNING clause
a
---
5
4
(2 rows)

drop table r_1240;
drop table p1_1240;
--
-- Clean up
--
DROP TABLE IF EXISTS T_a1 CASCADE;
Expand Down
12 changes: 12 additions & 0 deletions src/test/regress/sql/union_gp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,18 @@ select json_data,id from my_table where json_data->>'age' = '30' union all sele
set optimizer_parallel_union to off;
drop table if exists my_table;

--
-- test Github issue https://github.com/apache/cloudberry/issues/1240
--
create table r_1240(a int) distributed replicated;
insert into r_1240 select generate_series(1,10);
create table p1_1240(a int) distributed by (a);
insert into p1_1240 select generate_series(1,3);
explain(costs off) with result as (update r_1240 set a = a +1 where a < 5 returning *) select * from result except select * from p1_1240;
with result as (update r_1240 set a = a +1 where a < 5 returning *) select * from result except select * from p1_1240;
drop table r_1240;
drop table p1_1240;

--
-- Clean up
--
Expand Down
Loading