Seddryck / Tseesecake

Tseesecake is a lightweight proxy for time-series query engines, supporting multiple database engines and storage providers, with a SQL dialect dedicated to time series
https://seddryck.github.io/Tseesecake
Apache License 2.0
2 stars 1 forks source link

Fill empty values created with BUCKET BY #76

Open Seddryck opened 1 year ago

Seddryck commented 1 year ago

The time range definition of the BUCKET BY ... RANGE BETWEEN ... AND ... (see #75) can return empty/null values if there is no data in the timeseries for these slots. It should be possible to define how to fill these slots with the FILL NULL ASOF (BEFORE|AFTER) clause.

The qualifier BEFORE means that we take the previous non-null value, where AFTER means that we're using the next non-null value.

SELECT
    Instant,
    SUM(Forecasted) AS Forecasted
FROM
    WindEnergy
BUCKET BY
    DAY
    RANGE BETWEEN '2022-12-25' AND '2022-12-31'
    FILL NULL ASOF AFTER

Is returning the following table:

Instant Forecasted
2022-12-25 450
2022-12-26 450
2022-12-27 450
2022-12-28 450
2022-12-29 540
2022-12-30 670
2022-12-31 480

The values for the dates 2022-12-25 to 2022-12-27 are a copy of the first non-null value appearing after them.