canhtran.me


Write a spark dataframe to hive table with overwrite mode

Since Spark 2.4, creating a managed table with nonempty location is not allowed. An exception is thrown when attempting to create a managed table with nonempty location.

This issue is specifically for overwrite mode

Workaround solution

df.write \
	.option("path", "s3://schema/table-name") \
	.mode("overwrite") \
	.saveAsTable("schema.table_name")