mustafasrepo commented on PR #9221:
URL: 
https://github.com/apache/arrow-datafusion/pull/9221#issuecomment-1956008485

   After thinking about the possible solutions, another approach might be for 
the table below
   
   a |
   -- |
   1
   2
   null
   3
   null
   4
   
   constructing a vector with same length where each entry contains the index 
of the previous non-null  entry.
   For the table above, this would be 
   non-null_pointers |
   -- | 
   -1
   0
   0
   1
   1
   3
   
   To find `LAG(2)` for the row=5 (where `a=4`). We would follow pointers twice 
(idx 5 -> 3, 3 ->1). Hence result would the value at index 1, which have `a=2`. 
For the `LEAD` we might need to reverse data, apply `LAG` as you suggest. If we 
encounter -1, that would indicate result is `None`. Because there is no more 
previous data.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to