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

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

7            3

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.;             follow

www.zeeklog.com  - Spark2 Can't write dataframe to parquet hive table : HiveFileFormat`. It doesn't match the specified...

98222 gold badges1212 silver badges3838 bronze badges                 asked Jan 9 '19 at 14:42

www.zeeklog.com  - Spark2 Can't write dataframe to parquet hive table : HiveFileFormat`. It doesn't match the specified...

7111 silver badge44 bronze badges

  • have you got any solution ? i am facing same issue..can you please let me know what is the work around –  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) –  Feb 9 '19 at 12:07
  • am using spark 2.3.0 .. is repartitions works on latest spark ? –  Feb 9 '19 at 15:34

1 Answer                     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.

Read more

印度统治阶级锁死底层人的5大阳谋

印度统治阶级锁死底层人的5大阳谋

基于社会学和心理学视角: 1. 情感道德: 统治阶级通过塑造道德规范和情感价值观,引导底层人群的行为。例如,宣扬“勤劳致富”“忍耐美德”等观念,让底层人接受现状并自我约束。这种道德框架往往掩盖结构性不平等,使人们将个人困境归咎于自身而非系统。 2. 欲望控制: 通过消费主义和媒体宣传,统治阶级刺激底层人的物质与社会欲望(如名牌、地位),但同时设置经济壁垒,使这些欲望难以实现。底层人被困在追求“更好生活”的循环中,精力被分散,无法聚焦于挑战权力结构。 3. 情绪煽动: 利用恐惧、愤怒或民族主义等情绪,统治阶级可以通过媒体或公共事件转移底层人对社会问题的注意力。例如,制造外部敌人或内部对立(如阶层、种族矛盾),让底层人内耗而非联合反抗。 4. 暴利诱惑: 通过展示少数“成功案例”或快速致富的机会(如赌博、投机),诱导底层人追逐短期暴利。这种机制不仅让底层人陷入经济风险,还强化了对现有经济体系的依赖,削弱长期变革的可能性。 5. 权力震撼: 通过展示统治阶级的权力(

By Ne0inhk