bit_count function
Applies to: Databricks SQL
Databricks Runtime
Returns the number of bits set in the argument.
To count bits in a BINARY expression use bitmap_count function.
Syntax
bit_count(expr)
Arguments
expr: ABIGINTorBOOLEANexpression.
Returns
An INTEGER.
Examples
SQL
> SELECT bit_count(0);
0
> SELECT bit_count(5);
2
> SELECT bit_count(-1);
64
> SELECT bit_count(true);
1