pyspark.sql.functions.shiftrightunsigned#

pyspark.sql.functions.shiftrightunsigned(col, numBits)[source]#

Unsigned shift the given value numBits right.

New in version 3.2.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or column name

input column of values to shift.

numBitsint

number of bits to shift.

Returns
Column

shifted value.

Examples

>>> import pyspark.sql.functions as sf
>>> spark.range(4).select("*", sf.shiftrightunsigned(sf.col('id') - 2, 1)).show()
+---+-------------------------------+
| id|shiftrightunsigned((id - 2), 1)|
+---+-------------------------------+
|  0|            9223372036854775807|
|  1|            9223372036854775807|
|  2|                              0|
|  3|                              0|
+---+-------------------------------+