다음을 통해 공유


bit_and

null이 아닌 모든 입력 값의 비트 AND를 반환하고, null이 없으면 null을 반환합니다.

문법

from pyspark.sql import functions as sf

sf.bit_and(col)

매개 변수

매개 변수 유형 Description
col pyspark.sql.Column 또는 열 이름 계산할 대상 열입니다.

Returns

pyspark.sql.Column: null이 아닌 모든 입력 값의 비트 AND이거나, null이 아니면 null입니다.

예시

예제 1: Null이 아닌 값이 모두 있는 비트 AND

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

예제 2: Null 값이 있는 비트 AND

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

예제 3: 모든 null 값이 있는 비트 AND

from pyspark.sql import functions as sf
from pyspark.sql.types import IntegerType, StructType, StructField
schema = StructType([StructField("c", IntegerType(), True)])
df = spark.createDataFrame([[None],[None],[None]], schema=schema)
df.select(sf.bit_and("c")).show()
+----------+
|bit_and(c)|
+----------+
|      NULL|
+----------+

예제 4: 단일 입력 값이 있는 비트 AND

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