v.23.3New Feature
Introduce widthBucket function with WIDTH_BUCKET alias
Introduce a functionwidthBucket(with aWIDTH_BUCKETalias for compatibility). #42974. #46790 (avoiderboi).
Why it matters
ThewidthBucket function provides users with a way to assign values into equi-width buckets or histogram bins. This is useful for data analysis tasks such as distribution segmentation, histogram creation, and range-based categorization, enhancing analytical capabilities within ClickHouse.How to use it
Use thewidthBucket function by calling it in your SQL queries to divide a numeric value into buckets. The function syntax is similar to:SELECT widthBucket(value, min_value, max_value, bucket_count) FROM tablewhere
value is the input number, min_value and max_value define the range for bucketing, and bucket_count specifies the number of buckets. The WIDTH_BUCKET alias can be used interchangeably.