https://delta.io logo
l

Lucas Zago

05/08/2023, 3:03 PM
Hi guys what's the difference between
mergeSchema
and
overwriteSchema
? When to use one instead other?
g

Gerhard Brueckl

05/08/2023, 3:08 PM
not all changes in schema can be merged - e.g. you cannot change the type of a column from
StringType()
to
IntegerType()
if you still need to do this, you need to overwrite schema and rewrite your date
1
l

Lucas Zago

05/08/2023, 3:23 PM
I got an error using
overwriteSchema
, I was adding some columns to original table, change to
mergeSchema
it works
g

Gerhard Brueckl

05/08/2023, 3:31 PM
thats sounds weird though - what was the change you did? are you also using
.mode("overwrite")
?
l

Lucas Zago

05/08/2023, 3:34 PM
It was complaining in
.mode("append")
, i changed also in
.mode("overwrite")
inside a if statement
g

Gerhard Brueckl

05/08/2023, 8:30 PM
What do you mean with inside an
if
? You either execute as append or as overwrite
1