United_Communit
New Contributor II

In Delta lab you can set up User MetaData so i will give you some tips

from delta import DeltaTable

# Create or load your Delta table

delta_table = DeltaTable.forPath(spark, "path_to_delta_table")

# Define your user metadata myccpay

user_meta_data = {"key1": "value1", "key2": "value2"}

# Set the userMetadata option in your Delta table write operation

delta_table.alias("df").merge(

  df.alias("new_data"),

  "df.id = new_data.id"

 ).whenMatchedUpdateAll()

 .whenNotMatchedInsertAll()

 .option("userMetadata", user_meta_data)

 .execute()

you should try this code.