Retry Copy Activity after Changing Data Type

Surya Raja 20 Reputation points
2023-10-10T17:23:40.19+00:00

I attempted to copy a file with 10,000 records from Azure Blob Storage to Azure SQL Database, but the pipeline failed due to a data type change in the target database. Only 8,000 records were copied, and 2,000 are still in the source database. After the failure, I changed the data type in the source file. Can I rerun the pipeline from the failed activity with the updated data type? Any suggestions would be appreciated.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,753 questions
{count} votes

1 answer

Sort by: Most helpful
  1. KeshavKiran-MSFT 391 Reputation points Microsoft Employee
    2023-10-10T22:26:28.73+00:00

    Hi @Surya Raja ,

    Thank you for reaching out with your question and for using the MS Q&A platform.

    When you mention the remaining 2000 records in the source database, I assume you’re referring to the source data lake storage. You’ve also noted that you’ve modified the data type in the source file. In the previous run, only 8000 records were successfully copied. Here’s a step-by-step guide on how to re-run the pipeline:

    1. Truncate the Destination Table: As you’ll be re-running the copy operation, it will attempt to copy all 10000 records again. This could potentially lead to duplication or failure due to primary key violation if you have primary key on the columns in SQL .

    If you want to avoid this or only update the data not present in the destination, consider using Upsert or you can truncate the table and do the complete data copy from source to the destination. To truncate the table, use the following command: Truncate Table [Tablename]. Please replace [Tablename] with your actual table name.

    Related Link- https://learn.microsoft.com/en-us/azure/data-factory/connector-sql-server?tabs=data-factory

    1. Reset Mapping in ADF: In Azure Data Factory (ADF), navigate to the mapping tab for the copy activity. Reset the mapping and make sure it reflects the changed data type. Once done, publish and re-run the pipeline.

    Mapping

    Please try these steps and let us know if they work for you or if you have any follow up questions.

    0 comments No comments