Upsert failing in Dataflow

sam nick 346 Reputation points
2023-05-25T04:59:23.9633333+00:00

I am reading data from multiple json files and loading them into a sql database. There are duplicates in the json files, but in the dataflow i have explicitly selected upsert. yet this fails at the id. What am i missing ?

User's image

User's image

The ID in the DB is set as the primary key User's image

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

2 answers

Sort by: Most helpful
  1. QuantumCache 20,366 Reputation points Moderator
    2023-05-30T21:39:15.6866667+00:00

    Hello @@sam nick, Just checking on this!

    Did you get a chance to see the suggestion given by KranthiPakala-MSFT in the previous comment?

    I was able to reproduce the exact error shown in your scenario!
    User's image

    Reason for Error: When i am trying to insert the Column with PK as shown below, the insert is failing!!!!

    Below Source CSV will make it fail!

    User's image

    I have removed the duplicate row from CSV and the activity is now success.

    Please make sure to have a look at the Upsert and Insert selection in the Sink settings.

    User's image

    Below is my Table design!

    User's image

    Could you please check the Alter Row condition in your Data Flow?
    Please let us know what is the condition you have set on the Alter Row, so that we too ty to repro the issue!!!

    User's image

    Below is the Alter row condition in my Data Flow.

    User's image

    If i use the Pipeline for Orchestrating the Copy from Source to Sink, I see there is no issue in the activity.

    User's image

    Please let us know if you need further help in this matter.

    1 person found this answer helpful.
    0 comments No comments

  2. KranthiPakala-MSFT 46,642 Reputation points Microsoft Employee Moderator
    2023-05-28T23:57:21.93+00:00

    @sam nick Welcome to Microsoft Q&A forum and thanks for reaching out here.

    As per the error message, it seems like something wrong with source data which is resulting in this behavior. To ensure the source data is correct, could you please try implementing error row handling in your flow so that if there is anything wrong with few of the source records, you can log them as part of error handling and reprocess them after fixing.

    For more info on Error row handling in ADF dataflows, please refer to this document: Handle SQL truncation error rows in Data Factory mapping data flows

    Another article related to same: How to Handle SQL DB Row-level Errors in ADF Data Flows

    Using this approach, you will be able to identify good rows and bad rows from your source data and you can plan to handle them accordingly.

    In case if you don't see any issues with your source data, then please us know.

    Thank you

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.