You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Julian Feinauer (Jira)" <ji...@apache.org> on 2019/09/14 06:32:00 UTC

[jira] [Created] (CALCITE-3345) Implement time_bucket function

Julian Feinauer created CALCITE-3345:
----------------------------------------

             Summary: Implement time_bucket function
                 Key: CALCITE-3345
                 URL: https://issues.apache.org/jira/browse/CALCITE-3345
             Project: Calcite
          Issue Type: New Feature
            Reporter: Julian Feinauer


See here for information on the `time_bucket` function: https://docs.timescale.com/latest/api#time_bucket

This is a more powerful version of the standard PostgreSQL date_trunc function. It allows for arbitrary time intervals instead of the second, minute, hour, etc. provided by date_trunc. The return value is the bucket's start time.

This would especially help with time averaging but keeps everything SQL compliant. E.g. queries like 

Example query from (https://www.timescale.com/):

{code:sql}
SELECT  time_bucket('10  seconds',  time)  AS  ten_second,
    machine_id,  avg(temperature)  AS  "avgT",
    min(temperature)  AS  "minT",  max(temperature)  AS  "maxT",
    last(temperature,  time)  AS  "lastT"
FROM  measurements
WHERE  machine_id  =  'C931baF7'
    AND  time  >  now()  -  interval  '150s'
GROUP  BY  ten_second
ORDER  BY  ten_second  DESC;
{code}




--
This message was sent by Atlassian Jira
(v8.3.2#803003)