I have a array of struct and I am trying to find count, sum, distinct values of struct column.
create table temp (regionkey smallint, name string, comment string, nations array<struct<n_nationkey:smallint,n_name:string,n_comment:string>>)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '|'
MAP KEYS TERMINATED BY ',';
When I try to run the query
select name,
count(nations.n_nationkey) as count,
sum(nations.n_nationkey) as sum,
ndv(nations.n_nationkey) as distinct_val
from temp
group by name
order by name;
I get the error
FAILED: UDFArgumentTypeException Only primitive type arguments are accepted but array<smallint> is passed.
What I want to do is find the count, sum and distinct value of n_nationkey.
Any help will be highly appreciated.