v.1.1.54370New Feature
Added maxIntersections Function for Maximum Intersecting Intervals in ClickHouse
Added themaxIntersections(left_col, right_col)aggregate function, which returns the maximum number of simultaneously intersecting intervals[left; right]. ThemaxIntersectionsPosition(left, right)function returns the beginning of the "maximum" interval. (Michael Furmur).
Why it matters
These functions solve the problem of efficiently identifying the peak overlap of intervals within a dataset. They enable users to analyze interval data to find the highest number of concurrent intervals and pinpoint where this maximum overlap begins, which is valuable for temporal or range-based analytics.How to use it
Use the aggregate functionmaxIntersections(left_col, right_col) by passing the columns defining interval boundaries. To find the start position of the interval with the maximum number of intersections, use maxIntersectionsPosition(left, right). For example:SELECT maxIntersections(start, end), maxIntersectionsPosition(start, end) FROM intervals_table;