spark SaveMode数据源写入模式

spark | 2019-09-13 10:02:39

整理一下spark SaveMode数据源写入模式,包括 异常 追加 覆盖 存在忽略


Scala/JavaAny LanguageMeaning
SaveMode.ErrorIfExists(default)"error" or "errorifexists"(default)

When saving a DataFrame to a data source, if data already exists, an exception is expected to be thrown

.如果存在就抛出异常

SaveMode.Append"append"

When saving a DataFrame to a data source, if data/table already exists, contents of the DataFrame are expected to be appended to existing data

.直接追加

SaveMode.Overwrite"overwrite"

Overwrite mode means that when saving a DataFrame to a data source, if data/table already exists, existing data is expected to be overwritten by the contents of the DataFrame

.覆盖数据

SaveMode.Ignore"ignore"

Ignore mode means that when saving a DataFrame to a data source, if data already exists, the save operation is expected to not save the contents of the DataFrame and to not change the existing data. This is similar to a CREATE TABLE IF NOT EXISTS in SQL

.数据已经存在就忽略,不做任何操作



登录后即可回复 登录 | 注册
    
关注编程学问公众号