sparksql中保存数据的几种方式

更新时间:2023-05-30 04:56:32 阅读: 评论:0

sparksql中保存数据的⼏种⽅式从官⽹来copy过来的⼏种模式描述:
how do you do是什么意思gotta get thatScala/Java Python Meaning
SaveMode.ErrorIfExists(default)"error"(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.
ErrorIfExists就是出现错误后,抛出错误
Append顾名思义,就是追加信息
intellectualOverwrite是覆盖
北京火星时代Ignore是如果存在则忽略
另外,如果没有指定存储模式,那么默认应该是SaveMode.ErrorIfExists,因为我重复保存后报了:already exists错误来着。
如何使⽤:
瓜子脸发型设计import org.apache.spark.sql._
card phoneval sqlContext = new org.apache.spark.sql.SQLContext(sc)草你吗
val df = sqlContext.load("/opt/modules/spark1.3.1/examples/src/main/resources/people.json")make的用法
英语日记
df.save("/opt/test/1","json", SaveMode.Overwrite)  //可以把SaveMode.Overwrite换成其他的⼏种形式喽一建分数线

本文发布于:2023-05-30 04:56:32,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/811310.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:模式   火星时代   保存   错误   追加   瓜子脸
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图