Home / Companies / Tinybird / Blog / Post Details
Content Deep Dive

ClickHouse ® tips #8: Generating time-series on ClickHouse ®

Blog post from Tinybird

Post Details
Company
Date Published
Author
Xoel Lopez
Word Count
327
Language
English
Hacker News Points
-
Summary

ClickHouse® does not have a direct equivalent to Postgres's generate_series function, but it offers alternative methods to achieve similar results. The numbers and range functions in ClickHouse® can generate integer sequences, while combining these with arrayJoin allows for similar functionality to generate_series. Although ClickHouse®'s functions primarily output integers, it is possible to generate time series by applying additional logic. For instance, you can create a DateTime series in ClickHouse® by specifying start and end points with a given step, using functions such as addHours, dateAdd, and timeSlots to manipulate time intervals. Additionally, you can generate date sequences by using the toDate function to convert DateTime values to Date objects, as demonstrated by generating all dates within a specific month.