Skip to content

Commit

Permalink
adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
paragikjain committed Jul 16, 2024
1 parent cd76b76 commit 1483bf9
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/test/regress/expected/merge_vcore.out
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,77 @@ WHEN MATCHED THEN DO NOTHING;
Filter: ('2'::bigint = id)
(11 rows)

DROP TABLE IF EXISTS source;
DROP TABLE IF EXISTS target;
-- Bug Fix Test as part of this PR
-- Test 1
CREATE TABLE source (
id int,
age int,
salary int
);
CREATE TABLE target (
id int,
age int,
salary int
);
SELECT create_distributed_table('source', 'id', colocate_with=>'none');
create_distributed_table
---------------------------------------------------------------------

(1 row)

SELECT create_distributed_table('target', 'id', colocate_with=>'none');
create_distributed_table
---------------------------------------------------------------------

(1 row)

INSERT INTO source (id, age, salary) VALUES (1,30, 100000);
MERGE INTO ONLY target USING source ON (source.id = target.id)
WHEN NOT MATCHED THEN
INSERT (id, salary) VALUES (source.id, source.salary);
SELECT * FROM TARGET;
id | age | salary
---------------------------------------------------------------------
1 | | 100000
(1 row)

DROP TABLE IF EXISTS source;
DROP TABLE IF EXISTS target;
-- Test 2
CREATE TABLE source (
id int,
age int,
salary int
);
CREATE TABLE target (
id int,
age int,
salary int
);
SELECT create_distributed_table('source', 'id', colocate_with=>'none');
create_distributed_table
---------------------------------------------------------------------

(1 row)

SELECT create_distributed_table('target', 'id', colocate_with=>'none');
create_distributed_table
---------------------------------------------------------------------

(1 row)

INSERT INTO source (id, age, salary) VALUES (1,30, 100000);
MERGE INTO ONLY target USING source ON (source.id = target.id)
WHEN NOT MATCHED THEN
INSERT (salary, id) VALUES (source.salary, source.id);
SELECT * FROM TARGET;
id | age | salary
---------------------------------------------------------------------
1 | | 100000
(1 row)

DROP TABLE IF EXISTS source;
DROP TABLE IF EXISTS target;
DROP SCHEMA IF EXISTS merge_vcore_schema CASCADE;

0 comments on commit 1483bf9

Please sign in to comment.