You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
setcitus.shard_count=4;
CREATETABLEcitus_distributed_target (tid integer, balance float, val text);
CREATETABLEcitus_reference_source (sid integer, delta float);
SELECT create_distributed_table('citus_distributed_target', 'tid');
SELECT create_reference_table('citus_reference_source');
INSERT INTO citus_distributed_target SELECT id, id *100, 'initial'FROM generate_series(1,5,2) AS id;
INSERT INTO citus_reference_source SELECT id, id *10FROM generate_series(1,4) AS id;
-- this is the correct behaviourBEGIN;
MERGE INTO citus_distributed_target t
USING citus_reference_source s
ONt.tid=s.sid
WHEN MATCHED THEN
UPDATESET balance = balance + delta, val = val ||' updated by merge'
WHEN NOT MATCHED THEN
INSERT VALUES (sid, delta, 'inserted by merge')
WHEN NOT MATCHED BY SOURCE THEN
UPDATESET val = val ||' not matched by source';
-- MERGE 5, meaning merge operated on 5 rowsselect*from citus_distributed_target order by tid;
tid | balance | val
-----+---------+-------------------------------1 | 110 | initial updated by merge
2 | 20 | inserted by merge
3 | 330 | initial updated by merge
4 | 40 | inserted by merge
5 | 500 | initial not matched by source
(5 rows)
rollback;
-- increase shard countSELECT alter_distributed_table('citus_distributed_target', shard_count:=8);
-- suddenly, WHEN NOT MATCHED BY SOURCE is ineffectiveBEGIN;
MERGE INTO citus_distributed_target t
USING citus_reference_source s
ONt.tid=s.sid
WHEN MATCHED THEN
UPDATESET balance = balance + delta, val = val ||' updated by merge'
WHEN NOT MATCHED THEN
INSERT VALUES (sid, delta, 'inserted by merge')
WHEN NOT MATCHED BY SOURCE THEN
UPDATESET val = val ||' not matched by source';
-- MERGE 4, meaning merge operated on only 4 rows-- last entry tid = 5 should have been updatedselect*from citus_distributed_target order by tid;
tid | balance | val
-----+---------+--------------------------1 | 110 | initial updated by merge
2 | 20 | inserted by merge
3 | 330 | initial updated by merge
4 | 40 | inserted by merge
5 | 500 | initial
(5 rows)
rollback;
It seems that the issue happens when we use a reference table or a Citus local table as a source, not a distributed table.
Also, it seems that the issue doesn't reproduce when there is enough data to populate all the shards of the table.
The text was updated successfully, but these errors were encountered:
Steps to reproduce:
It seems that the issue happens when we use a reference table or a Citus local table as a source, not a distributed table.
Also, it seems that the issue doesn't reproduce when there is enough data to populate all the shards of the table.
The text was updated successfully, but these errors were encountered: