Reputation: 312
With the "upsert
option" , should I expect to see "0" as "Rows Written
" in a copy activity result summary?
My situation is this: The source and sink table columns are not exactly the same but the Key columns to tell it how to know the write behavior are correct.
I have tested and made sure that it does actually do insert or update based on the data I give to it BUT what I don't understand is if I make ZERO changes and just keep running the pipeline , why does it not show "zero" in the Rows Written
summary?
Upvotes: 1
Views: 17041
Reputation: 35
Marked solution is misleading. For the situation described in the question, a write action is indeed performed on each record, even if there is no difference between the source and the target. The only difference seems to be whether that write action is a create or an update, i.e. which plugins will trigger.
Upvotes: 0
Reputation: 267
Upsert only updates the record if it is present in both source and target tables and inserts if not present in the target and present in source.
Not sure why in the above answer it was mentioned that "it is modifying all records irrespective of the changes in data." and it is not true.
Upvotes: 4
Reputation: 6114
The main reason why rowsWritten is not shown as 0
even when the source and destination have same data is:
Upsert
inserts data when a key column value is absent in target table and updates the values of other rows whenever the key column is found in target table.Merge
, there is no way to tell copy activity that if an entire row already exists in target table, then ignore that case.key_column
matches, it is going to update the values for rest of the columns and hence counted as row written. The following is an example of 2 casesThe rows of source and sink are same:
id,gname
1,Ana
2,Ceb
3,Topias
4,Jerax
6,Miracle
When inserting completely new rows:
id,gname
8,Sumail
9,ATF
Upvotes: 2