Skip to content

Miscellaneous

WhenStatement

Bases: Column

Represents a chained CASE WHEN expression. Use .when() to add branches and .otherwise() for a default.

when

when(condition: Bool, value: C) -> WhenStatement[C]

Adds another WHEN condition THEN value branch to the expression.

Wrapper for pyspark.sql.Column.when.

otherwise

otherwise(value: C) -> C

Adds a final ELSE value clause to the expression.

Wrapper for pyspark.sql.Column.otherwise.

StrEnumWhen

Bases: StringOf[E]

A CASE WHEN expression over the members of a StrEnum. Use .when() to add branches and .otherwise() for a default.

when

when(
    condition: Bool, value: E | StringOf[E]
) -> StrEnumWhen[E]

Adds another WHEN condition THEN value branch to the expression.

Wrapper for pyspark.sql.Column.when.

otherwise

otherwise(value: E | StringOf[E]) -> StringOf[E]

Adds a final ELSE value clause to the expression.

Wrapper for pyspark.sql.Column.otherwise.

IntEnumWhen

Bases: IntOf[E]

A CASE WHEN expression over the members of an IntEnum. Use .when() to add branches and .otherwise() for a default.

when

when(
    condition: Bool, value: E | IntOf[E]
) -> IntEnumWhen[E]

Adds another WHEN condition THEN value branch to the expression.

Wrapper for pyspark.sql.Column.when.

otherwise

otherwise(value: E | IntOf[E]) -> IntOf[E]

Adds a final ELSE value clause to the expression.

Wrapper for pyspark.sql.Column.otherwise.

bitwise_not

bitwise_not(col: T) -> T

Returns the bitwise NOT of col.

Wrapper for pyspark.sql.functions.bitwise_not.

crc32

crc32(col: Binary) -> Long

Returns the CRC-32 checksum of col as an unsigned integer.

Wrapper for pyspark.sql.functions.crc32.

current_date

current_date() -> Date

Returns the current date at query start time.

Wrapper for pyspark.sql.functions.current_date.

current_timestamp

current_timestamp() -> Timestamp

Returns the current timestamp at query start time.

Wrapper for pyspark.sql.functions.current_timestamp.

equal_null

equal_null(col1: Column[T], col2: Column[T]) -> Bool

Returns true if col1 equals col2, treating null as equal to null.

Wrapper for pyspark.sql.functions.equal_null.

from_json

from_json(
    col: String,
    schema: type[T],
    options: dict[str, str] | None = None,
) -> T
from_json(
    col: String,
    schema: type[Array[E]],
    options: dict[str, str] | None = None,
) -> Array[E]
from_json(
    col: String,
    schema: StructType,
    options: dict[str, str] | None = None,
) -> Column
from_json(
    col: String,
    schema: type[T] | type[Array] | StructType,
    options: dict[str, str] | None = None,
) -> Column | T

Parses a JSON string column into a struct or array.

  • Pass a Struct subclass for a typed struct result.
  • Pass an Array[X] class for a typed array result.
  • Pass a PySpark StructType for an untyped Column.

Wrapper for pyspark.sql.functions.from_json.

greatest

greatest(*cols: T) -> T

Returns the largest value among the given columns, skipping nulls.

Wrapper for pyspark.sql.functions.greatest.

hash

hash(col: Column) -> Int

Returns a hash value for col using the default hash algorithm.

Wrapper for pyspark.sql.functions.hash.

isnan

isnan(col: Numeric) -> Bool

Returns true if col is NaN.

Wrapper for pyspark.sql.functions.isnan.

isnull

isnull(col: Column) -> Bool

Returns true if col is null.

Wrapper for pyspark.sql.functions.isnull.

isnotnull

isnotnull(col: Column) -> Bool

Returns true if col is not null.

Wrapper for pyspark.sql.functions.isnotnull.

least

least(*cols: T) -> T

Returns the smallest value among the given columns, skipping nulls.

Wrapper for pyspark.sql.functions.least.

coalesce

coalesce(*cols: C) -> C

Returns the first non-null value from the given columns.

Wrapper for pyspark.sql.functions.coalesce.

lit

lit(value: str) -> String
lit(value: bool) -> Bool
lit(value: int) -> Long
lit(value: float) -> Double
lit(value: LiteralType) -> Column

Creates a column from a Python literal value.

Wrapper for pyspark.sql.functions.lit.

md5

md5(col: Column) -> String

Returns the MD5 hex digest of col.

Wrapper for pyspark.sql.functions.md5.

monotonically_increasing_id

monotonically_increasing_id() -> Long

Returns a monotonically increasing 64-bit integer that is unique per row, but not consecutive.

Wrapper for pyspark.sql.functions.monotonically_increasing_id.

nanvl

nanvl(col1: T, col2: T) -> T

Returns col1 if it is not NaN, otherwise returns col2.

Wrapper for pyspark.sql.functions.nanvl.

nullif

nullif(col1: C, col2: C) -> C

Returns null if col1 equals col2, otherwise returns col1.

Wrapper for pyspark.sql.functions.nullif.

nvl

nvl(col1: C, col2: C) -> C

Returns col1 if it is not null, otherwise returns col2.

Wrapper for pyspark.sql.functions.nvl.

nvl2

nvl2(col1: Column, col2: C, col3: C) -> C

Returns col2 if col1 is not null, otherwise returns col3.

Wrapper for pyspark.sql.functions.nvl2.

spark_partition_id

spark_partition_id() -> Int

Returns the partition ID of the current row.

Wrapper for pyspark.sql.functions.spark_partition_id.

typeof

typeof(col: Column) -> String

Returns the Spark SQL data type name of col as a string.

Wrapper for pyspark.sql.functions.typeof.

base64

base64(col: Binary) -> String

Encodes binary column col as a Base64 string.

Wrapper for pyspark.sql.functions.base64.

version

version() -> String

Returns the Spark version as a string.

Wrapper for pyspark.sql.functions.version.

when

when(condition: Bool, value: E) -> StrEnumWhen[E]
when(condition: Bool, value: E) -> IntEnumWhen[E]
when(condition: Bool, value: C) -> WhenStatement[C]
when(
    condition: Bool, value: StrEnum | IntEnum | Column
) -> Column

Starts a CASE WHEN condition THEN value expression. Chain .when() and .otherwise() to complete it.

Passing a StrEnum or IntEnum member gives a StringOf[E] or IntOf[E] result.

Wrapper for pyspark.sql.functions.when.

xxhash64

xxhash64(*cols: Column) -> Long

Returns a 64-bit hash of the given columns using the xxHash algorithm.

Wrapper for pyspark.sql.functions.xxhash64.