首页 > 其他 > 详细

Spark2 Can't write dataframe to parquet hive table : HiveFileFormat`. It doesn't match the specified format `ParquetFileFormat`

时间:2020-08-14 14:27:18      阅读:92      评论:0      收藏:0      [点我收藏+]
7

I‘m trying to save dataframe in table hive.

In spark 1.6 it‘s work but after migration to 2.2.0 it doesn‘t work anymore.

Here‘s the code:

blocs
      .toDF()
      .repartition($"col1", $"col2", $"col3", $"col4")
      .write
      .format("parquet")
      .mode(saveMode)
      .partitionBy("col1", "col2", "col3", "col4")
      .saveAsTable("db".tbl)

The format of the existing table project_bsc_dhr.bloc_views is HiveFileFormat. It doesn‘t match the specified format ParquetFileFormat.; org.apache.spark.sql.AnalysisException: The format of the existing table project_bsc_dhr.bloc_views is HiveFileFormat. It doesn‘t match the specified format ParquetFileFormat.;

share  improve this question   
  •  
    have you got any solution ? i am facing same issue..can you please let me know what is the work around – BigD Feb 8 ‘19 at 11:42
  •  
    Yes, i used insertInto instead of saveAsTable and i deleted partitionby. The code: blocs .toDF() .repartition($"col1", $"col2", $"col3", $"col4") .write .format("parquet") .insertInto("db".tbl) – youssef grati Feb 9 ‘19 at 12:07 
  •  
    am using spark 2.3.0 .. is repartitions works on latest spark ? – BigD Feb 9 ‘19 at 15:34 
8

I have just tried to use .format("hive") to saveAsTable after getting the error and it worked.

I also would not recommend to use insertInto suggested by the author, because it looks not type-safe (as much as this term can be applied to SQL API) and is error-prone in the way it ignores column names and uses position-base resolution.

Spark2 Can't write dataframe to parquet hive table : HiveFileFormat`. It doesn't match the specified format `ParquetFileFormat`

原文:https://www.cnblogs.com/felixzh/p/13501857.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!