Width bucket

サポート対象:バッチ、高速、ストリーミング

Splits the range from the minimum to the maximum value into a number of equal-width buckets and returns the 1-based bucket a value falls in. Returns 0 for a value before the range and the number of buckets plus one for a value after it. If the minimum is greater than the maximum, the buckets are numbered from the minimum down. Returns null if the number of buckets is not positive or is the maximum long, if the bounds are equal or not finite, or if the value is not a number.

式のカテゴリー: 数値

引数

  • Expression: Number to find the bucket of.
    Expression<Numeric>
  • Maximum value: End of the bucketed range.
    Expression<Numeric>
  • Minimum value: Start of the bucketed range.
    Expression<Numeric>
  • Number of buckets: Number of buckets to split the range into.
    Expression<Byte | Integer | Long | Short>

出力タイプ: Long

例

例1:基本ケース

説明: The second value is before the range and the third after it. The fourth range runs down from its minimum.

引数の値:

  • Expression: value
  • Maximum value: max
  • Minimum value: min
  • Number of buckets: buckets
valueminmaxbuckets出力
5.30.210.653
-2.11.33.430
8.10.05.745
4.010.00.054

例2:Null ケース

引数の値:

  • Expression: value
  • Maximum value: max
  • Minimum value: min
  • Number of buckets: buckets
valueminmaxbuckets出力
null0.010.05null
5.0null10.05null
5.00.0null5null
5.00.010.0nullnull