Vensterfuncties gebruiken:
select t.*,
coalesce(next_time, time) as imputed_time
from (select t.*,
sum(context = 'reset') over (partition by user_id) as cnt_reset,
min(case when context is null then time end) over (partition by userid order by time rows between current row and unbounded following) as next_time
from t
) t
where cnt_reset = 0 or context = 'reset';