IDEA SPARK与HIVE交互报错集合

IDEA SPARK与HIVE交互报错集合,第1张

IDEA SPARK与HIVE交互报错集合

问题概览
  • 1、Spark Dataframe 写入HIve 出现HiveFileFormat. It doesn't match the specified format ParquetFileFormat
    • 解决方法1:
    • 解决方法2:
    • 解决方法3:

1、Spark Dataframe 写入HIve 出现HiveFileFormat. It doesn’t match the specified format ParquetFileFormat

详细报错信息:org.apache.spark.sql.AnalysisException: The format of the existing table mydata.test3 is `HiveFileFormat`. It doesn’t match the specified format `ParquetFileFormat`.;

解决方法1:

df.write.format(“Hive”).mode(SaveMode.Append).saveAsTable(“test3”)


解决方法2:

其实,还可以一种方式,就是使用insertInto,但是不太建议。因为在insertInto源码中,这样写道:
insertInto插入的时候,是根据列的位置插入,而不是根据列的名字。表的format和设置的options也会被忽略。所以不是很推荐,但是也能达到目标。

df.write.insertInto(“test3”)

解决方法3:

还有一种方式,就是先将dataframe注册成临时表,然后通过sql的方式,插入

df.createOrReplaceTempView(“temp_tab”)
spark.sql(“insert into test3 select * from temp_tab”)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5656549.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存