- 1、Spark Dataframe 写入HIve 出现HiveFileFormat. It doesn't match the specified format ParquetFileFormat
- 解决方法1:
- 解决方法2:
- 解决方法3:
详细报错信息: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”)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)