timeBucket

Create time buckets for the given table.

Create time buckets for the input table. Each event is assigned to a time bucket based on its start and end time. The start time of the bucket is saved in lhub_start_ts and the end time of the bucket is saved in lhub_end_ts for each event.

Usage Details

select *, timeBucket(column, bucketDef) as timebucket from table

Input
column: The column to run timeBucket on. This column needs to have integers in it.
bucketDef: String that defines a time bucket. The string has the following format: (integer)('s' or 'm' or 'h' or 'd') where 's' stands for seconds, 'm' stands for minutes, 'h' stands for hours, and 'd' stands for days. Some examples of valid strings are the following: "3s" = 3 seconds "5m" = 5 minutes

Output
The column named in the UDF invocation will have the start time of the time buckets for each row.

Example

Input
table

lhub_ts
11/30/2017 23:35:29
11/30/2017 23:35:44
11/30/2017 23:35:54
select *, timeBucket(lhub_ts, "1m") as timebucket from table

Output

lhub_tstimebucket
11/30/2017 23:35:2911/30/2017 23:35:00
11/30/2017 23:35:4411/30/2017 23:35:00
11/30/2017 23:35:5411/30/2017 23:35:00

Did this page help you?