解析配置单元中的异常

时间:2018-10-04 11:20:24

标签: hive hiveql

我建立了一个配置单元查询,该查询将连接2个表并获取列的总和,并在此基础上编写了一个嵌套的case语句,如下所示:

select purchasing_document, pdoc_litem, po_quantity, po_value,gr_quantity, gr_value, ir_quantity, ir_value, 
case 
when po_quantity != '0' then
case    
when gr_quantity != '0' then
case
when ir_quantity = '0' then 'Invoice qty not posted'
when ir_quantity != '0' and gr_quantity > ir_quantity then 'Invoice qty is partially posted'
when gr_quantity < ir_quantity then 'Invoice qty exceeds GR qty '
else 'Invoice qty is completely posted' end
when gr_quantity = '0' then
case
when ir_quantity != '0' then 'Invoice qty exceeds GR qty where GR qty = 0'
else 'Both GR and Invoice qty not posted at all' end
else '' end
else 'PO qty not present' end as comment1
from
( select  a.purchasing_document, a.pdoc_litem ,
               sum(b.re_quantity)    ir_quantity,
               min(b.re_quantity)    min_ir_quantity,
               sum(b.re_value)       ir_value,
               sum(a.we_quantity)    gr_quantity,
               min(a.we_quantity)    min_gr_quantity,
               sum(a.we_value)       gr_value,
               min(a.Po_quantity) po_quantity,
               min(a.PO_value)    po_value
       from grir_data_we_only a join grir_data_re_only b ON (a.pdoc_litem = b.pdoc_litem)
       group by purchasing_document, pdoc_litem 
       )s order by     purchasing_document, pdoc_litem limit 10;

但是我收到以下错误:

FAILED: ParseException line 5:0 cannot recognize input near 'when' 'gr_quantity' '!=' in expression specification

您能帮忙吗?谢谢!

0 个答案:

没有答案