Thanks for posting your question in the Microsoft Q&A forum.
Here’s how you can approach it:
- Import necessary libraries and create DataFrames and then using DataFrame APIs such as
join
andunion
. here’s how you can insert rows fromdf1
intodf2
whencol1
values do not already exist indf2
:df_to_insert = df1.join(df2, df1.col1 == df2.col1, 'left_anti') updated_df2 = df2.union(df_to_insert)
- Once you have the merged DataFrame, you can write it back to Azure Synapse Analytics
updated_df2.write \ .format("synapsesql") \ .mode("overwrite") \ # Choose appropriate write mode .option("table", "table2") \ .save()
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful