darsha1706 commented on issue #7656:
URL: https://github.com/apache/iceberg/issues/7656#issuecomment-1577090186

   hi @Thijsvandepoll ,
   
   you can try this
   
   def merge_row(row):
       merged = spark.sql(f"""
           MERGE INTO {namespace}.{table} A
           USING (SELECT {row.col1} AS col1, {row.col2} AS col2) B
           ON A.col1 = B.col1
           WHEN MATCHED THEN UPDATE SET A.col1 = B.col1, A.col2 = B.col2
           WHEN NOT MATCHED THEN INSERT *
       """)
   
   # Apply the UDF transformation
   df = df.withColumn("col1", return_self("col1"))
   
   # Iterate over each row and perform the merge operation
   df.foreach(merge_row)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to