The reason for the problem UPDATE/MERGE must match at most one source row for each target row
is that your INNER JOIN in the first query tries to update rows in documents_bkup
when there are several matching rows in transactions_bkup
depending on transaction_header_guid
. Because an INNER JOIN returns all matching rows from both tables, the update statement becomes unclear which case_guid
to use if a transaction_header_guid
from documents_bkup
appears more than once in transactions_bkup
with various case_guid
values. Due this ambiguity, bigquery throws an error. Refer to this documentation for more information.
Using aggregate functions in the JOIN clause to choose a single case_guid
for each transaction_header_guid
may be necessary to use the INNER JOIN successfully (e.g., MIN(case_guid), MAX(case_guid)) And also refer this stack link1, link2.