spark与hive查询得出的数据不同

2020-10-29  本文已影响0人  有机会一起种地OT

在实际工作的情况中,经常有spark与hive查询出来的数据存在不一样的情况,基本的原因如下:
1、由于精度不一样导致的
2、更多的时候确实是由于元数据混乱导致的
(就是说hive中能读到这个字段的值,但是在spark中却无法读取到该字段的值。
很多时候可能还是由于大小写的混乱所导致的)

同一条sql,hive能生成表,而spark却生成的一张空表,或者数据缺少,存在null值,与hive结果不一致
设置
spark.sql.hive.convertMetastoreOrc=false
convertMetastoreParquet=false

原因:
spark用自己的格式读取hive文件后进行自动转换后进行操作

官方说明

spark.sql.hive.convertMetastoreParquet :
When reading from and writing to Hive metastore Parquet tables, Spark SQL will try to use its own Parquet support instead of Hive SerDe for better performance. This behavior is controlled by the spark.sql.hive.convertMetastoreParquet configuration, and is turned on by default.

spark.sql.hive.convertMetastoreOrc:
enables new ORC format to read/write Hive Tables.

上一篇 下一篇

猜你喜欢

热点阅读