错误类型:org.apache.hadoop.hive.ql.parse.SemanticException:Line 55:23 Cannot insert into target table because column number/types are different ''2020-06-14'': Cannot convert column 7 from array<struct<sku_id:string,sku_num:bigint,order_count:bigint,order_amount:decimal(30,2)>> to array<struct<sku_id:string,sku_num:bigint,order_count:bigint,order_amount:decimal(20,2)>>.

错误原因:尽管在hive建表时对decimal规定为(20,2),但是hive在计算时就有可能出现浮点数精度转换为(30,2),所以需要进行精度强转。 注意在查询是不会报错,但是将子查询结果插入到表中就会出现精度不匹配问题。

解决方法:精度转换:cast(sum(final_amount_d) as decimal(20,2))

1.建表语句

hive on spark 精度匹配异常

2.精度匹配异常

hive on spark 精度匹配异常

相关文章:

  • 2021-04-15
  • 2021-06-12
  • 2022-01-03
  • 2022-12-23
  • 2021-12-23
  • 2021-11-28
猜你喜欢
  • 2021-05-21
  • 2021-09-24
  • 2021-08-01
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
相关资源
相似解决方案