EQUIWIDTH_BUCKET (Lakehouse v2)
Returns the bucket number for a value in an equi-width histogram. Divides the range [min, max] into equal-width intervals.
Analyze Syntax
Section titled “Analyze Syntax”func.equiwidth_bucket(<expr>, <min>, <max>, <num_buckets>)Analyze Examples
Section titled “Analyze Examples”func.equiwidth_bucket(75, 0, 100, 10)
┌───┐│ 8 │└───┘SQL Syntax
Section titled “SQL Syntax”EQUIWIDTH_BUCKET(<expr>, <min>, <max>, <num_buckets>)SQL Examples
Section titled “SQL Examples”SELECT score, EQUIWIDTH_BUCKET(score, 0, 100, 10) AS bucketFROM students;
┌───────┬────────┐│ score │ bucket │├───────┼────────┤│ 25 │ 3 ││ 75 │ 8 ││ 95 │ 10 │└───────┴────────┘