Jennifer Pip
Jennifer Pip

BigQuery Error: UPDATE/MERGE must match at most one source row for each target row

Twitter
LinkedIn

Using the SQL MERGE statement with BigQuery can be a huge boost to analytical transformation and data analysis processing but it does have a few gotchas. This error message “UPDATE/MERGE must match at most one source row for each target row” is typically seen when attempting the SQL MERGE statement into a target table and most often occurs when you have duplicate records in the source table you are using in the USING part of the MERGE statement.

One way to quickly assert what is going on in your data is to query the dataset/schema table looking for duplicate records. For example:

SELECT
  __ROW_MD5,
  COUNT(*)
FROM
  `SOURCE_DATASET.SOURCE_TABLE`
GROUP BY
  __ROW_MD5
HAVING
  COUNT(*) > 1 ;

The above SQL will do a basic check on the set of data in the table and identify if you have any rows with a count greater than one (1).

If that is the case then this is most likely the culprit to the UPDATE/MERGE must match at most one source row for each target row issue. Remove the duplicate records in the source table by adjusting your process or data accordingly and it should resolve your issue.

Feel free to read up other details about the SQL MERGE statement in BigQuery.

More to explorer

International Women's Day 2024

International Women’s Day 2024: Empowerment and Progress

As we commemorate International Women’s Day on March 8th each year, it’s a time to honor the resilience, accomplishments, and contributions of women worldwide. In 2024, this day holds particular significance as we take stock of the strides made, acknowledge persistent challenges, and recommit ourselves to the pursuit of gender equality.

Bank grade security

5 Steps to Configure Key Pair Authentication in Snowflake

Key pair authentication is a secure way to access your Snowflake data warehouse without relying solely on traditional username and password authentication. In this step-by-step guide, we will walk you through the process of setting up key pair authentication in Snowflake. We’ll also cover how to install OpenSSL, a crucial tool for generating the necessary key pair.

streamline-processes

Streamlining Your Bullhorn CRM: Mastering Duplicate Data Management

Discover the most effective strategies for eliminating duplicate records in your Bullhorn CRM. Duplicates can hinder your productivity, lead to data inaccuracies, and impact your relationships with clients and candidates. In this insightful session, we will guide you through best practices, cutting-edge tools, and proven techniques to ensure a clean and efficient CRM database.

Scroll to Top