I know there should be merge schema for new field but not sure about detail steps. Can anyone guide with detailed step ?
I tried to reproduce the same in my environment and got below results:
For demo , I created delta table in this location /mnt/defaultDatalake/KK1
Now, I performed the merge operation updated and added a new column field with the value into the existing delta table in that location using below code.
from pyspark.sql.functions import lit
spark.read.format("delta").load('/mnt/defaultDatalake/KK1')\
.withColumn("Recovered", lit('USA'))\
.write\
.format("delta")\
.mode("overwrite")\
.option("overwriteSchema", "true")\
.save('/mnt/defaultDatalake/KK1')
Now you can check , I got new column called Recovered
.