v.22.11New Feature
Support for Composite Time Intervals in ClickHouse
Support for composite time intervals. 1. Add, subtract and negate operations are now available on Intervals. In the case where the types of Intervals are different, they will be transformed into the Tuple of those types. 2. A tuple of intervals can be added to or subtracted from a Date/DateTime field. 3. Added parsing of Intervals with different types, for example: INTERVAL '1 HOUR 1 MINUTE 1 SECOND'. #42195 (Nikolay Degterinsky).Why it matters
This enhancement solves the limitation of handling only single-unit intervals by enabling users to perform addition, subtraction, and negation on complex intervals composed of multiple units. It improves expressiveness and convenience when working with dates and times by allowing more natural time interval representations and calculations.How to use it
Users can now directly add, subtract, or negate intervals even when they are of different types; these operations automatically return a tuple representing the composite interval. Additionally, tuples of intervals can be added to or subtracted fromDate or DateTime fields. To specify a composite interval, use the SQL syntax like:INTERVAL '1 HOUR 1 MINUTE 1 SECOND'No special settings are needed – this functionality works out-of-the-box with the new interval parsing and arithmetic support.