user11069271
user11069271

Reputation: 119

Hive ignore nulls

I am trying to rewrite last value(col1 ignore nulls ) analytical function in hive from RDMS.

I used select last_value(col1,TRUE)

But I am getting null as output when used for above query. Can someone please suggest is there any other way to ignore nulls in analytic function in hive.

Upvotes: 0

Views: 2451

Answers (1)

pb7708
pb7708

Reputation: 31

The default comparison method of the OVER() function is to compare the current row with all previous rows. You need to add a sentence after the order by statement: rows between unbounded preceding and unbounded following:

last_value(col1,TRUE) over (partition by col1 order by col2 rows between unbounded preceding and unbounded following)

Upvotes: 1

Related Questions