v.25.4New Feature

Introduce toInterval function

Introduce toInterval function. This function accepts 2 arguments (value and unit), and converts the value to a specific Interval type. #78723 (Andrew Davis).
Introduces the toInterval function that converts a given numeric value and unit into a specific ClickHouse Interval type.

Why it matters

This feature simplifies the creation of interval types by allowing users to specify a value and its corresponding time unit, which ClickHouse then converts to the appropriate Interval. It helps improve query clarity and reduces the need for manual interval construction.

How to use it

Call the toInterval function with two arguments: the numeric value and the unit as a string. For example:

SELECT toInterval(5, 'day')

This will convert the value 5 to an interval of 5 days.