v.1.1.54370New Feature

Added maxIntersections Function for Maximum Intersecting Intervals in ClickHouse

Added the maxIntersections(left_col, right_col) aggregate function, which returns the maximum number of simultaneously intersecting intervals [left; right]. The maxIntersectionsPosition(left, right) function returns the beginning of the "maximum" interval. (Michael Furmur).
Added the maxIntersections(left_col, right_col) aggregate function to calculate the maximum number of simultaneously intersecting intervals in the data, and maxIntersectionsPosition(left, right) to return the start position of the interval where this maximum occurs.

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 function maxIntersections(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;