I have a table that contains the actions of a user (e.g. view page, click button, etc). Each row contains a user_id a date (created_on) and the name of the action. I would like to create a query that for each date it would create a nested field of the distinct actions taken up to and including that date. For example, I have a table called user_actions:
-------------------------------------
| user_id | date | action |
-------------------------------------
| 1 | 2018-04-01 | click |
| 2 | 2018-04-01 | view |
| 1 | 2018-04-02 | view |
| 2 | 2018-04-02 | view |
| 2 | 2018-04-03 | buy |
-------------------------------------
would result in
-------------------------------------
| user_id | date | actions |
-------------------------------------
| 1 | 2018-04-01 | click |
| 2 | 2018-04-01 | view |
| 1 | 2018-04-02 | click |
| 2 | 2018-04-02 | view |
| | | view |
| 2 | 2018-04-03 | view |
| 2 | | buy |
-------------------------------------
In the second table, actions is a nested repeated field. I know that for a single point in time I can use something similar to the following:
SELECT
user_id,
date,
ARRAY(action)
FROM
user_actions
GROUP BY
1,2
However I am unsure how to extend this out to provide the same calculation for every date in the original table and only look at the time before the date field.
Any help would be greatly appreciated. Thanks!

