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 10.4 LTS and above
Returns the value of a bit in a binary representation of an integral numeric. This function is a synonym of bit_get function.
Syntax
getbit(expr, pos))
Arguments
expr: An expression that evaluates to an integral numeric.pos: An expression of type INTEGER.
Returns
The result type is INTEGER.
The result value is 1 if the bit is set, 0 otherwise.
Bits are counted right to left and 0-based.
If pos is outside the bounds of the data type of expr Azure Databricks raises an INVALID_PARAMETER_VALUE error.
Common error conditions
Examples
> SELECT hex(23Y), getbit(23Y, 3);
0
> SELECT hex(23Y), getbit(23Y, 0);
1
> SELECT getbit(23Y, 8);
Error: INVALID_PARAMETER_VALUE.BIT_POSITION_RANGE
> SELECT getbit(23Y, -1);
Error: INVALID_PARAMETER_VALUE.BIT_POSITION_RANGE