简体   繁体   中英

How to add a new column into delta table without overwrite in scala

I have big delta table in Azure Blob Storage Container. It stores very big size data. Now I want to add a new column to this existing delta table. For all existing data, I want to give default value 1. Option 1, I can read whole delta table, add new column, then overwrite. But I don't want to overwrite. Is there other way, we can add a new column without overwrite, just give default value 1 for all existing rows?

You can try as below

df.write.format("delta").mode("append").option("mergeSchema", "true").saveAsTable("tablename")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM