Incompatible return types 'DECIMAL(38,7)' of exprs xxx

问题描述/异常栈

org.apache.impala.common.AnalysisException: Incompatible return types 'DECIMAL(38,7)' and 'DECIMAL(37,4)' of exprs 't1.year_pdemand_qty_mtd / 10000' and 'round(t1.year_avg_wgt_mtd / t1.year_pdemand_qty_mtd, 4)'.

解决方案

统一精度:
case 
    when t1.target_number='a' then round(t1.rolling_fresh_wgt_mtd/1000,4)
    when t1.target_number='b' then round(t1.rolling_pdemand_qty_mtd/10000,4)
    when t1.target_number='c' then round(t1.rolling_avg_wgt_mtd/t1.rolling_pdemand_qty_mtd,4)
    else round(t11.rolling_value,4)

问题原因

下列条件中精度不一致

Incompatible return types 'DECIMAL(38,7)' of exprs - 图1


作者:林帅