Reputation: 41
While I am applying a complex formula in HIVE SQL, I got into a situation where I need to multiply three different derived values(using some other columns). Multiplication of these three NOT NULL columns is returning NULL as output. Need help.
The data type of the base columns from where the values are getting derived is DECIMAL(18,6)
Thanks in advance
Upvotes: 1
Views: 750
Reputation: 41
Thanks Kishore for your suggestion.
It worked if I cast all the three operands individually.
cast(a) as decimal(18,6) * cast(b) as decimal(18,6) * cast(c) as decimal(18,6);
Upvotes: 1
Reputation: 5881
try this, CAST the final output where you multiple the three values.
cast((a*b*c) as decimal(18,6));
where a,b,c is your derived column. Note that if the multiplication causing overflow, you will have to cast one of the operators to a type higher in the type hierarchy mean int to long.
Upvotes: 0