EXPAND only works on PERIODs, you have to construct one on the fly.
SELECT name, newdate,
SUM(CASE WHEN datecol = newdate THEN measure ELSE 0 END)
OVER (PARTITION BY name
ORDER BY newdate
ROWS UNBOUNDED PRECEDING)
FROM
(
SELECT name, measure, datecol, BEGIN(pd2) AS newdate
FROM
(
SELECT
name, datecol, measure,
PERIOD(datecol,
COALESCE(MIN(datecol)
OVER (PARTITION BY name
ORDER BY datecol
ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING), CURRENT_DATE)) AS pd
FROM tab
) AS dt
EXPAND ON pd AS pd2 BY INTERVAL '1' DAY
FOR PERIOD(DATE '2013-07-01', DATE '2013-07-04')
) AS dt
Of course this will still require lots of resources and might return much more than your original 139M rows.
I did something like this, but only for a small subsets of rows. i.e. displaying for end users.
Why do you need it for all rows?
Dieter
EXPAND only works on PERIODs, you have to construct one on the fly.
Of course this will still require lots of resources and might return much more than your original 139M rows.
I did something like this, but only for a small subsets of rows. i.e. displaying for end users.
Why do you need it for all rows?
Dieter