Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Databricks SQL
Databricks Runtime 13.3 LTS and above
Returns the bitmap bucket number for a given BIGINT number.
This function is used in combination with the bitmap_count() function to count distinct integral numbers.
In combination with the bitmap_bit_position() function it uniquely identifies any BIGINT number.
Syntax
bitmap_bucket_number(expr)
Arguments
expr: ABIGINTexpression.
Returns
A BIGINT.
If expr is >0 the result matches: ((expr - 1) DIV 32768) + 1.
If expr is <= 0 the result matches: expr DIV 32768.
Examples
> SELECT bitmap_bucket_number(1), bitmap_bit_position(1);
1 0
> SELECT bitmap_bucket_number(32768), bitmap_bit_position(32768);
1 32767
> SELECT bitmap_bucket_number(32769), bitmap_bit_position(32769);
2 0
> SELECT bitmap_bucket_number(0), bitmap_bit_position(0);
0 0
> SELECT bitmap_bucket_number(-32767), bitmap_bit_position(-32767);
0 32767
> SELECT bitmap_bucket_number(-32768), bitmap_bit_position(-32768);
-1 0