Created 03-21-2021 11:56 PM
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.
Created 03-22-2021 12:10 AM
Created 03-21-2021 11:59 PM
The documentation is here:
https://docs.cloudera.com/documentation/enterprise/6/6.3/topics/impala_udf.html
You can either implement Impala UDF using C++ or Hive UDF using Java
Created 03-22-2021 12:01 AM
Thanks for your quick response. Although I wrote that I have read clouderas documentation about UDFS and it didnt help me a lot. Is there any source with examples?
Created 03-22-2021 12:10 AM