eqNullSafe

Prueba de igualdad que es segura para valores NULL.

Agregado en Databricks Runtime 11.0

Modificado en Databricks Runtime 13.0: admite Spark Connect.

Sintaxis

eqNullSafe(other)

Parámetros

Parámetro Tipo Descripción
other Columna o valor Valor o Columna que se va a comparar

Devoluciones

Columna

Notas

A diferencia de Pandas, PySpark no considera que los valores NaN sean NULL. Consulte la semántica de NaN para obtener más información.

Ejemplos

from pyspark.sql import Row
df1 = spark.createDataFrame([
    Row(id=1, value='foo'),
    Row(id=2, value=None)
])
df1.select(
    df1['value'] == 'foo',
    df1['value'].eqNullSafe('foo'),
    df1['value'].eqNullSafe(None)
).show()
# +-------------+---------------+----------------+
# |(value = foo)|(value <=> foo)|(value <=> NULL)|
# +-------------+---------------+----------------+
# |         true|           true|           false|
# |         NULL|          false|            true|
# +-------------+---------------+----------------+