Kopīgot, izmantojot


bit_or

Returns the bitwise OR of all non-null input values, or null if none.

Syntax

from pyspark.sql import functions as sf

sf.bit_or(col)

Parameters

Parameter Type Description
col pyspark.sql.Column or column name Target column to compute on.

Returns

pyspark.sql.Column: the bitwise OR of all non-null input values, or null if none.

Examples

Example 1: Bitwise OR with all non-null values

from pyspark.sql import functions as sf
df = spark.createDataFrame([[1],[1],[2]], ["c"])
df.select(sf.bit_or("c")).show()
+---------+
|bit_or(c)|
+---------+
|        3|
+---------+

Example 2: Bitwise OR with some null values

from pyspark.sql import functions as sf
df = spark.createDataFrame([[1],[None],[2]], ["c"])
df.select(sf.bit_or("c")).show()
+---------+
|bit_or(c)|
+---------+
|        3|
+---------+