Skip to content

Commit

Permalink
Fix icw test cases generted from "ORCA support ext stats, Fix EPQ..."
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaqizho committed Jan 15, 2025
1 parent 6a5f2f7 commit 1fcfb03
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 127 deletions.
27 changes: 27 additions & 0 deletions src/test/isolation2/expected/gdd/concurrent_update_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,33 @@ DROP
1q: ... <quitting>
2q: ... <quitting>

-- test ORCA partition table
create table test(a int, b int, c int) partition by range(b) (start (1) end (7) every (3));
CREATE
insert into test values (1, 1, 1);
INSERT 1
1: begin;
BEGIN
1: delete from test where b = 1;
DELETE 1
-- in session 2, in case of ORCA DML invokes EPQ
-- the following SQL will hang due to XID lock
2&: update test set b = 1; <waiting ...>
1: end;
END
2<: <... completed>
UPDATE 0

0: select * from test;
a | b | c
---+---+---
(0 rows)
0: drop table test;
DROP
0q: ... <quitting>
1q: ... <quitting>
2q: ... <quitting>

-- split update is to implement updating on hash keys,
-- it deletes the tuple and insert a new tuple in a
-- new segment, so it is not easy for other transaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ explain (costs off) delete from tab1 using tab2, tab3 where tab1.a = tab2.a and
-> Redistribute Motion 3:3 (slice1; segments: 3)
Hash Key: tab1.b
-> Hash Join
Hash Cond: (tab3.a = tab1.b)
-> Seq Scan on tab3
Hash Cond: (tab2.a = tab1.a)
-> Seq Scan on tab2
-> Hash
-> Broadcast Motion 3:3 (slice2; segments: 3)
-> Hash Join
Hash Cond: (tab2.a = tab1.a)
-> Seq Scan on tab2
Hash Cond: (tab3.a = tab1.b)
-> Seq Scan on tab3
-> Hash
-> Broadcast Motion 3:3 (slice3; segments: 3)
-> Seq Scan on tab1
Optimizer: Pivotal Optimizer (GPORCA) version 3.86.0
Optimizer: Pivotal Optimizer (GPORCA)
(16 rows)
begin;
BEGIN
Expand Down Expand Up @@ -182,16 +182,18 @@ ABORT
-- the to-delete tuple is set to send back where it is from, so
-- it will not error out.
explain (costs off) update tab1 set b = b + 1;
QUERY PLAN
------------------------------------------------------------
Update on tab1
-> Result
-> Redistribute Motion 3:3 (slice1; segments: 3)
Hash Key: b
-> Split
-> Seq Scan on tab1
Optimizer: Pivotal Optimizer (GPORCA) version 3.86.0
(7 rows)
QUERY PLAN
------------------------------------------------------------------
Update on tab1
-> Result
One-Time Filter: true
-> Result
-> Redistribute Motion 3:3 (slice1; segments: 3)
Hash Key: b
-> Split
-> Seq Scan on tab1
Optimizer: Pivotal Optimizer (GPORCA)
(9 rows)
begin;
BEGIN
update tab1 set b = b + 1;
Expand Down
26 changes: 14 additions & 12 deletions src/test/regress/expected/bfv_dml_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,20 @@ select * from update_pk_test order by 1,2;
(1 row)

explain update update_pk_test set a = 5;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------
Update on update_pk_test (cost=0.00..431.07 rows=1 width=1)
-> Result (cost=0.00..431.00 rows=1 width=26)
-> Sort (cost=0.00..431.00 rows=1 width=22)
Sort Key: (DMLAction)
-> Redistribute Motion 3:3 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=22)
Hash Key: update_pk_test_1.a
-> Split (cost=0.00..431.00 rows=1 width=22)
-> Seq Scan on update_pk_test (cost=0.00..431.00 rows=1 width=18)
Optimizer: Pivotal Optimizer (GPORCA) version 3.83.0
(9 rows)
QUERY PLAN
-------------------------------------------------------------------------------------------------------------
Update on update_pk_test (cost=0.00..431.06 rows=1 width=1)
-> Result (cost=0.00..0.00 rows=0 width=0)
One-Time Filter: true
-> Result (cost=0.00..0.00 rows=0 width=0)
-> Sort (cost=0.00..431.00 rows=2 width=22)
Sort Key: (DMLAction)
-> Redistribute Motion 3:3 (slice1; segments: 3) (cost=0.00..431.00 rows=2 width=22)
Hash Key: a
-> Split (cost=0.00..431.00 rows=1 width=22)
-> Seq Scan on update_pk_test (cost=0.00..431.00 rows=1 width=18)
Optimizer: Pivotal Optimizer (GPORCA)
(11 rows)

update update_pk_test set a = 5;
select * from update_pk_test order by 1,2;
Expand Down
18 changes: 10 additions & 8 deletions src/test/regress/expected/direct_dispatch.out
Original file line number Diff line number Diff line change
Expand Up @@ -1270,14 +1270,14 @@ INFO: (slice 1) Dispatch command to SINGLE content
explain (costs off) select gp_segment_id, * from t1_varchar where col1_varchar = 'c'::char;
QUERY PLAN
--------------------------------------------------------------
Gather Motion 1:1 (slice1; segments: 1)
Gather Motion 3:1 (slice1; segments: 3)
-> Seq Scan on t1_varchar
Filter: ((col1_varchar)::bpchar = 'c'::character(1))
Optimizer: Postgres query optimizer
(4 rows)

select gp_segment_id, * from t1_varchar where col1_varchar = 'c'::char;
INFO: (slice 1) Dispatch command to SINGLE content
INFO: (slice 1) Dispatch command to ALL contents: 0 1 2
gp_segment_id | col1_varchar | col2_int
---------------+--------------+----------
2 | c | 3
Expand All @@ -1286,14 +1286,14 @@ INFO: (slice 1) Dispatch command to SINGLE content
explain (costs off) select gp_segment_id, * from t1_varchar where col1_varchar = '2'::char;
QUERY PLAN
--------------------------------------------------------------
Gather Motion 1:1 (slice1; segments: 1)
Gather Motion 3:1 (slice1; segments: 3)
-> Seq Scan on t1_varchar
Filter: ((col1_varchar)::bpchar = '2'::character(1))
Optimizer: Postgres query optimizer
(4 rows)

select gp_segment_id, * from t1_varchar where col1_varchar = '2'::char;
INFO: (slice 1) Dispatch command to SINGLE content
INFO: (slice 1) Dispatch command to ALL contents: 0 1 2
gp_segment_id | col1_varchar | col2_int
---------------+--------------+----------
(0 rows)
Expand Down Expand Up @@ -1359,14 +1359,14 @@ INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL cont
explain (costs off) select LOWER(name) as aba FROM srt_dd WHERE name = 'ABA'::text;
QUERY PLAN
----------------------------------------------
Gather Motion 1:1 (slice1; segments: 1)
Gather Motion 3:1 (slice1; segments: 3)
-> Seq Scan on srt_dd
Filter: ((name)::text = 'ABA'::text)
Optimizer: Postgres query optimizer
(4 rows)

select LOWER(name) as aba FROM srt_dd WHERE name = 'ABA'::text;
INFO: (slice 1) Dispatch command to SINGLE content
INFO: (slice 1) Dispatch command to ALL contents: 0 1 2
aba
-----
aba
Expand All @@ -1382,8 +1382,9 @@ explain (costs off) delete from srt_dd where name='ABA'::text;
(4 rows)

delete from srt_dd where name='ABA'::text;
INFO: (slice 0) Dispatch command to SINGLE content
INFO: Distributed transaction command 'Distributed Commit (one-phase)' to SINGLE content
INFO: (slice 0) Dispatch command to ALL contents: 0 1 2
INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2
INFO: Distributed transaction command 'Distributed Commit Prepared' to ALL contents: 0 1 2
drop extension if exists citext cascade;
NOTICE: drop cascades to table srt_dd
INFO: Distributed transaction command 'Distributed Prepare' to ALL contents: 0 1 2
Expand Down Expand Up @@ -1606,6 +1607,7 @@ set allow_system_table_mods=off;
-- If opno of clause does not belong to opfamily of distributed key,
-- do not use direct dispatch to resolve wrong result
-- FIXME: orca still has wrong results
-- CBDB_MERGE_FIXME: known ORCA direct dispatch BUG
create table t_14887(a varchar);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database 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.
Expand Down
10 changes: 5 additions & 5 deletions src/test/regress/expected/direct_dispatch_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,7 @@ set allow_system_table_mods=off;
-- If opno of clause does not belong to opfamily of distributed key,
-- do not use direct dispatch to resolve wrong result
-- FIXME: orca still has wrong results
-- CBDB_MERGE_FIXME: known ORCA direct dispatch BUG
create table t_14887(a varchar);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database 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.
Expand All @@ -1639,10 +1640,9 @@ explain select * from t_14887 where a = 'a'::bpchar;
(4 rows)

select * from t_14887 where a = 'a'::bpchar;
a
------
a
(1 row)
a
---
(0 rows)

-- texteq does not belong to the hash opfamily of the table's citext distkey.
-- But from the implementation can deduce: texteq ==> citext_eq, and we can
Expand All @@ -1659,7 +1659,7 @@ insert into t_14887 values('A'),('a');
explain select * from t_14887 where a = 'a'::text;
QUERY PLAN
------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.00 rows=1 width=8)
Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..431.00 rows=1 width=8)
-> Seq Scan on t_14887 (cost=0.00..431.00 rows=1 width=8)
Filter: ((a)::text = 'a'::text)
Optimizer: Pivotal Optimizer (GPORCA)
Expand Down
1 change: 1 addition & 0 deletions src/test/regress/expected/gporca.out
Original file line number Diff line number Diff line change
Expand Up @@ -14640,4 +14640,5 @@ select * from conf;
---------

(1 row)

reset optimizer_trace_fallback;
22 changes: 13 additions & 9 deletions src/test/regress/expected/gporca_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -14486,15 +14486,16 @@ ON t1.tradingday = t2.tradingday;
-> Dynamic Index Scan on t_clientproductind2_pkey on t_clientproductind2
Index Cond: (((tradingday)::text >= '20190715'::text) AND ((tradingday)::text <= '20190715'::text) AND ((tradingday)::text = '20190715'::text))
Number of partitions to scan: 1
-> GroupAggregate
Group Key: t_clientinstrumentind2.tradingday
-> Sort
Sort Key: t_clientinstrumentind2.tradingday
-> Redistribute Motion 3:3 (slice2; segments: 3)
Hash Key: t_clientinstrumentind2.tradingday
-> Dynamic Index Scan on t_clientinstrumentind2_pkey on t_clientinstrumentind2
Index Cond: ((tradingday >= '20190715'::text) AND (tradingday <= '20190715'::text) AND (tradingday = '20190715'::text))
Number of partitions to scan: 1
-> Materialize
-> GroupAggregate
Group Key: t_clientinstrumentind2.tradingday
-> Sort
Sort Key: t_clientinstrumentind2.tradingday
-> Redistribute Motion 3:3 (slice2; segments: 3)
Hash Key: t_clientinstrumentind2.tradingday
-> Dynamic Index Scan on t_clientinstrumentind2_pkey on t_clientinstrumentind2
Index Cond: ((tradingday >= '20190715'::text) AND (tradingday <= '20190715'::text) AND (tradingday = '20190715'::text))
Number of partitions to scan: 1
Optimizer: Pivotal Optimizer (GPORCA)
(22 rows)

Expand All @@ -14511,6 +14512,8 @@ INNER JOIN (
WHERE t.tradingday BETWEEN'20190715'AND '20190715'
GROUP BY t.tradingday)t2
ON t1.tradingday = t2.tradingday;
INFO: GPORCA failed to produce a plan, falling back to planner
DETAIL: No plan has been computed for required properties
tradingday | ins_spaninsarbitrageratio | tradingday | prod_spaninsarbitrageratio
------------+---------------------------+------------+----------------------------
20190715 | 1 | 20190715 | 0.9233716475
Expand Down Expand Up @@ -14763,4 +14766,5 @@ select * from conf;
---------

(1 row)

reset optimizer_trace_fallback;
30 changes: 16 additions & 14 deletions src/test/regress/expected/join_optimizer.out
Original file line number Diff line number Diff line change
Expand Up @@ -3372,18 +3372,19 @@ select * from
tenk1 join int4_tbl on f1 = twothousand,
q1, q2
where q1 = thousand or q2 = thousand;
QUERY PLAN
--------------------------------------------------------------------------
QUERY PLAN
------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3)
-> Hash Join
Hash Cond: (tenk1.twothousand = int4_tbl.f1)
-> Nested Loop
Join Filter: true
-> Nested Loop
Join Filter: true
-> Result
-> Materialize
-> Result
-> Broadcast Motion 3:3 (slice2; segments: 3)
-> Nested Loop
Join Filter: true
-> Broadcast Motion 3:3 (slice3; segments: 3)
-> Seq Scan on q1
-> Seq Scan on q2
-> Bitmap Heap Scan on tenk1
Recheck Cond: ((thousand = q1.q1) OR (thousand = q2.q2))
-> BitmapOr
Expand All @@ -3395,7 +3396,7 @@ where q1 = thousand or q2 = thousand;
-> Broadcast Motion 3:3 (slice4; segments: 3)
-> Seq Scan on int4_tbl
Optimizer: Pivotal Optimizer (GPORCA)
(21 rows)
(22 rows)

explain (costs off)
select * from
Expand All @@ -3409,18 +3410,19 @@ where thousand = (q1 + q2);
Hash Cond: (tenk1.twothousand = int4_tbl.f1)
-> Nested Loop
Join Filter: true
-> Nested Loop
Join Filter: true
-> Result
-> Materialize
-> Result
-> Broadcast Motion 3:3 (slice2; segments: 3)
-> Nested Loop
Join Filter: true
-> Broadcast Motion 3:3 (slice3; segments: 3)
-> Seq Scan on q1
-> Seq Scan on q2
-> Index Scan using tenk1_thous_tenthous on tenk1
Index Cond: (thousand = (q1.q1 + q2.q2))
-> Hash
-> Broadcast Motion 3:3 (slice4; segments: 3)
-> Seq Scan on int4_tbl
Optimizer: Pivotal Optimizer (GPORCA)
(16 rows)
(17 rows)

--
-- test ability to generate a suitable plan for a star-schema query
Expand Down
Loading

0 comments on commit 1fcfb03

Please sign in to comment.