v.22.9Improvement

More natural conversion of Date types to narrower types in ClickHouse

More natural conversion of Date32, DateTime64, Date to narrower types: upper or lower normal value is considered when out of normal range. #40217 (Andrey Zvonov).
Improved conversion logic for Date32, DateTime64, and Date types to narrower types that considers upper or lower boundary values when the original value is out of the target type's normal range.

Why it matters

This feature addresses issues with converting date and datetime types to narrower types by ensuring conversions use the closest valid boundary value instead of failing or producing invalid results. It enhances data compatibility and reduces errors when downcasting date/time types.

How to use it

The improved conversion behavior is applied automatically during type casting operations involving Date32, DateTime64, or Date to narrower date/time types. No additional configuration is required.