Query editor
WITH delegated_power_changes_by_token AS ( -- has the gov power for each day with a change in voting powerSELECTDATE_TRUNC('day', evt_block_time) AS "date", evt_block_time, evt_index, user, amount -- raw amount, not adjusted for decimals, 'AAVE' AS tokenFROM query_2970577 aave_delegated_power_changesWHERE delegationType = 0UNION ALLSELECTDATE_TRUNC('day', evt_block_time) AS "date", evt_block_time, evt_index, user, amount -- raw amount, not adjusted for decimals, 'stkAAVE' AS tokenFROM query_2984707 stkaave_delegated_power_changesWHERE delegationType = 0), last_daily_delegated_power_changes_by_token AS (SELECTuser, "date", token, MAX(evt_block_time) AS last_timestamp, MAX(evt_index) AS last_evt_indexFROM delegated_power_changes_by_tokenGROUP BY user, "date", token), daily_delegated_power_by_token_with_gaps AS (SELECTld.user, ld."date", ld.token, dpc.evt_block_time, dpc.evt_index, dpc.amount / POWER(10, 18) AS amount -- now amount becomes adjusted for decimals, LEAD(ld."date", 1, CURRENT_DATE) OVER (PARTITION BY ld.user, ld.token ORDER BY ld."date") AS next_day -- The day after a day with a transfer-- This is the field that then creates the forward fill effect and the increased granularityFROM last_daily_delegated_power_changes_by_token ld LEFT JOIN delegated_power_changes_by_token dpcON ld.user = dpc.userAND ld.token = dpc.tokenAND ld.last_timestamp = dpc.evt_block_timeAND ld.last_evt_index = dpc.evt_index), date_seq AS (SELECT SEQUENCE(CAST('2016-01-20' AS DATE), DATE_TRUNC('day', CURRENT_DATE)) AS "date" -- Generate all days since the first contract), date_series AS (SELECT CAST(days."date" AS TIMESTAMP) AS "date"FROM date_seq CROSS JOIN UNNEST("date") AS days("date") -- This is just doing explode like in spark sql)