Solved
How can I create a udf in impala
Hi
I perform many queries with the below statement and I thought that instead of writing over and over again the same cases if it is possible to create a UDF in impala to handle this like sql server.
(select people, sum(new_money) as new_money from
(
select people,
case
when pocket_01 = 'leather' then sum(nvl(money,0.0))/100 else 0.0
end +
case
when pocket_02 = 'leather' then sum(nvl(money,0.0))/100 else 0.0
end +
case
when pocket_03 = 'leather' then sum(nvl(money,0.0))/100 else 0.0
end +
case
when pocket_04 = 'leather' then sum(nvl(money,0.0))/100 else 0.0
end +
case
when pocket_05 = 'leather' then sum(nvl(money,0.0))/100 else 0.0
end +
case
when pocket_06 = 'leather' then sum(nvl(money,0.0))/100 else 0.0
end +
case
when pocket_07 = 'leather' then sum(nvl(money,0.0))/100 else 0.0
end ) as new_money from bank where date = '20201010'
) target
group by people ) as target
Is this possible? I have searched everywhere to find a simple example of how to create a udf but I only found this in the cloudera documentation which didnt help me a lot.

