Error reported in the coalesce function on Alibaba Cloud

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TimoHa
    New Member
    • Nov 2017
    • 22

    Error reported in the coalesce function on Alibaba Cloud

    Error was reported every time I used more than one expression in the coalesce function:
    FAILED: ODPS-0130071:Semanti c analysis exception - Expression not in GROUP BY key : line 8:9 ''$.table''
    The SQL statement is as follows:
    SELECT
    md5(concat(aid, bid)) as id
    ,aid
    , bid
    , sum(amountdue) as amountdue
    , coalesce(
    sum(regexp_coun t(get_json_obje ct(extended_x, '$.table.tableP arties'), '{')),
    decode(get_json _object(extende d_x, '$.table'), NULL, 0, 1)
    ) as tableparty
    , decode(sum(head count),null,0,s um(headcount) ) as headcount
    , 'a' as pt
    FROM e_orders
    where pt='20170425'
    group by aid, bid
  • Andrea1701
    New Member
    • Nov 2017
    • 34

    #2
    You need to add all the grouping fields after "group by". The returned value of your expression
    coalesce(
    sum(regexp_coun t(get_json_obje ct(extended_x, '$.table.tableP arties'), '{')),
    decode(get_json _object(extende d_x, '$.table'), NULL, 0, 1)
    ) as tableparty
    , decode(sum(head count),null,0,s um(headcount) ) as headcount
    is actually a field, too. You need to add the entire expression after "group by".

    Comment

    Working...