错误类型: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.建表语句
2.精度匹配异常