Pulkit Sharma created HIVE-22487:
------------------------------------

             Summary: Windowing functions (first_value and last_value) doesnot 
ignore null values until non-null value is found
                 Key: HIVE-22487
                 URL: https://issues.apache.org/jira/browse/HIVE-22487
             Project: Hive
          Issue Type: Bug
            Reporter: Pulkit Sharma


Windowing functions (first_value and last_value) does not ignore null values 
until it encounters the first non-null value. If the non-null value for field 
is found, it shows first_value/last_value as null until the non-null value for 
field is found.


How to reproduce :
{code:java}
create table test_first_value(state string, seats int, name string);
insert into test_first_value values('CA', 16, null);
insert into test_first_value values('CA', 17, 'CA17');
insert into test_first_value values('CA', 18, 'CA18');
insert into test_first_value values('CA', 19, null);
insert into test_first_value values('CA', 20, null);
insert into test_first_value values('CA', 21, null);
select state, seats, name, first_value(name, true) over (PARTITION by state 
order by seats desc ) from test_first_value;
Results : 
CA 21 NULL NULL
CA 20 NULL NULL
CA 19 NULL NULL
CA 18 CA18 CA18
CA 17 CA17 CA18
CA 16 NULL CA18
{code}
In this case, col4 is first_value(name) with _ignore nulls_ as true but we 
still got NULL in first three rows.

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to