From 7c8a366ba2cf18e7ab8cb273e3716cb94b3c6376 Mon Sep 17 00:00:00 2001 From: paragjain Date: Fri, 14 Jun 2024 04:39:17 +0000 Subject: [PATCH] some more --- src/test/regress/expected/merge.out | 21 +++++++++++++++++++-- src/test/regress/multi_schedule | 3 ++- src/test/regress/sql/merge.sql | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/test/regress/expected/merge.out b/src/test/regress/expected/merge.out index 188ed897e..1a7e58f36 100644 --- a/src/test/regress/expected/merge.out +++ b/src/test/regress/expected/merge.out @@ -1965,8 +1965,8 @@ on t.id = s.somekey WHEN NOT MATCHED THEN INSERT (id) VALUES (s.somekey); -DEBUG: MERGE INSERT must use the source table distribution column value, try repartitioning -DEBUG: MERGE INSERT must use the source table distribution column value +DEBUG: MERGE INSERT must use the source table distribution column value for push down to workers. Otherwise, repartitioning will be applied +DEBUG: MERGE INSERT must use the source table distribution column value for push down to workers. Otherwise, repartitioning will be applied DEBUG: Creating MERGE repartition plan DEBUG: Using column - index:0 from the source list to redistribute QUERY PLAN @@ -2118,6 +2118,23 @@ SELECT * FROM target_table; --------------------------------------------------------------------- (0 rows) +-- +DELETE FROM source_withdata; +DELETE FROM target_table; +INSERT INTO source VALUES (1,1); +merge into target_table sda +using source_withdata sdn +on sda.id = sdn.id AND sda.id = 1 +when not matched then + insert (id) + values (10000); +ERROR: MERGE INSERT is using unsupported expression type for distribution column +DETAIL: Inserting arbitrary values that don't correspond to the joined column values can lead to unpredictable outcomes where rows are incorrectly distributed among different shards +SELECT * FROM target_table WHERE id = 10000; + id | name +--------------------------------------------------------------------- +(0 rows) + RESET client_min_messages; -- This will prune shards with restriction information as NOT MATCHED is void BEGIN; diff --git a/src/test/regress/multi_schedule b/src/test/regress/multi_schedule index fca36f5ab..7f0c7ca57 100644 --- a/src/test/regress/multi_schedule +++ b/src/test/regress/multi_schedule @@ -116,7 +116,8 @@ test: function_with_case_when test: clock # MERGE tests -test: merge pgmerge merge_repartition2 +test: merge pgmerge +test: merge_repartition2 test: merge_repartition1 merge_schema_sharding test: merge_partition_tables diff --git a/src/test/regress/sql/merge.sql b/src/test/regress/sql/merge.sql index cc7f0d9a6..4538d8d81 100644 --- a/src/test/regress/sql/merge.sql +++ b/src/test/regress/sql/merge.sql @@ -1308,6 +1308,20 @@ WHEN MATCHED THEN -- let's verify if data deleted properly. SELECT * FROM target_table; +-- +DELETE FROM source_withdata; +DELETE FROM target_table; +INSERT INTO source VALUES (1,1); + +merge into target_table sda +using source_withdata sdn +on sda.id = sdn.id AND sda.id = 1 +when not matched then + insert (id) + values (10000); + +SELECT * FROM target_table WHERE id = 10000; + RESET client_min_messages;