v.22.4New Feature
INTERVAL enhancement with new time functions in ClickHouse
INTERVAL improvement - can be used with[MILLI|MICRO|NANO]SECOND. AddedtoStartOf[Milli|Micro|Nano]second()functions. Added[add|subtract][Milli|Micro|Nano]seconds(). #34353 (Andrey Zvonov).
Why it matters
This feature enables finer-grained time interval handling in ClickHouse by allowing users to work with sub-second precision intervals. It improves time-series data manipulation capabilities, allowing precise truncation and arithmetic operations at millisecond, microsecond, and nanosecond levels, thus increasing flexibility and accuracy in time-based queries.How to use it
Use the new INTERVAL unitsMILLISECOND, MICROSECOND, and NANOSECOND in time interval expressions. Call the new functions like toStartOfMillisecond(), toStartOfMicrosecond(), or toStartOfNanosecond() to truncate timestamps. Use arithmetic functions such as addMilliseconds(), subtractMicroseconds(), and addNanoseconds() to perform precise time additions or subtractions.