Forum Discussion
QuinnDatatyk
2 years agoFrequent Visitor
Spark Write to OneLake cannot overwrite data schema
I cannot overwrite table schema using spark.write.mode("overwrite") For example, create a table with 2 column: col1 as int and col2 as string Then change col1 to data type int and use spark.w...
- 2 years ago
I think if you want to overwrite the schema while overwriting the data, you could write like this:
df\ .write\ .mode("overwrite")\ .option("overwriteSchema", "true")\ .saveAsTable("tableName")So I think you only need to add .option("overwriteSchema", "true") in your code
frithjof_v
2 years agoCommunity Champion
I think if you want to overwrite the schema while overwriting the data, you could write like this:
df\
.write\
.mode("overwrite")\
.option("overwriteSchema", "true")\
.saveAsTable("tableName")
So I think you only need to add .option("overwriteSchema", "true") in your code
QuinnDatatyk
2 years agoFrequent Visitor
I tried and successed. Thank you very much.