Skip to content

Array

array

array(*cols: C) -> Array[C]

Creates an array column from the given columns.

Wrapper for pyspark.sql.functions.array.

array_append

array_append(col: Array[T], value: T) -> Array[T]

Appends value to the end of array col.

Wrapper for pyspark.sql.functions.array_append.

array_compact

array_compact(col: A) -> A

Removes null elements from array col.

Wrapper for pyspark.sql.functions.array_compact.

array_contains

array_contains(col: Array[T], value: T) -> Bool

Returns true if array col contains value.

Wrapper for pyspark.sql.functions.array_contains.

array_distinct

array_distinct(col: A) -> A

Returns an array with duplicate elements removed from col.

Wrapper for pyspark.sql.functions.array_distinct.

array_except

array_except(col1: A, col2: A) -> A

Returns elements in col1 that are not in col2, without duplicates.

Wrapper for pyspark.sql.functions.array_except.

array_insert

array_insert(
    arr: Array[T], pos: Integer | int, value: T
) -> Array[T]

Inserts value into array arr at position pos (1-based). Negative positions count from the end.

Wrapper for pyspark.sql.functions.array_insert.

array_intersect

array_intersect(col1: A, col2: A) -> A

Returns the intersection of col1 and col2, without duplicates.

Wrapper for pyspark.sql.functions.array_intersect.

array_join

array_join(
    col: Array[String],
    delimiter: str,
    nullReplacement: str | None = None,
) -> String

Joins elements of string array col into a single string using delimiter. Replaces nulls with nullReplacement when provided.

Wrapper for pyspark.sql.functions.array_join.

array_max

array_max(col: Array[T]) -> T

Returns the maximum element in array col.

Wrapper for pyspark.sql.functions.array_max.

array_min

array_min(col: Array[T]) -> T

Returns the minimum element in array col.

Wrapper for pyspark.sql.functions.array_min.

array_position

array_position(col: Array[T], value: T) -> Long

Returns the 1-based position of the first occurrence of value in array col, or 0 if not found.

Wrapper for pyspark.sql.functions.array_position.

array_prepend

array_prepend(col: Array[T], value: T) -> Array[T]

Prepends value to the beginning of array col.

Wrapper for pyspark.sql.functions.array_prepend.

array_remove

array_remove(col: Array[T], element: T) -> Array[T]

Removes all occurrences of element from array col.

Wrapper for pyspark.sql.functions.array_remove.

array_repeat

array_repeat(col: T, count: Integer | int) -> Array[T]

Returns an array containing col repeated count times.

Wrapper for pyspark.sql.functions.array_repeat.

array_size

array_size(col: Array[T]) -> Int

Returns the number of elements in array col, or -1 for null.

Wrapper for pyspark.sql.functions.array_size.

array_sort

array_sort(col: A) -> A

Returns array col sorted in ascending order, with nulls last.

Wrapper for pyspark.sql.functions.array_sort.

array_union

array_union(col1: A, col2: A) -> A

Returns the union of col1 and col2, without duplicates.

Wrapper for pyspark.sql.functions.array_union.

arrays_overlap

arrays_overlap(a1: A, a2: A) -> Bool

Returns true if arrays a1 and a2 share at least one non-null element.

Wrapper for pyspark.sql.functions.arrays_overlap.

broadcast

broadcast(df: T) -> T

Marks df for broadcast join, hinting the optimizer to replicate it to all workers.

Wrapper for pyspark.sql.functions.broadcast.

cardinality

cardinality(col: Array) -> Int

Returns the number of elements in array col, or -1 for null.

Wrapper for pyspark.sql.functions.cardinality.

element_at

element_at(
    col: Array[T], extraction: Integer | int
) -> T

Returns the element at position extraction in array col (1-based; negative counts from end).

Wrapper for pyspark.sql.functions.element_at.

try_element_at

try_element_at(
    col: Array[T], extraction: Integer | int
) -> T

Returns the element at position extraction in array col (1-based; negative counts from end). Returns null if the index exceeds the array length, instead of raising an error.

Wrapper for pyspark.sql.functions.try_element_at.

explode

explode(col: Array[T]) -> T

Explodes array col into separate rows. Rows with null or empty arrays are dropped.

Wrapper for pyspark.sql.functions.explode.

explode_outer

explode_outer(col: Array[T]) -> T

Explodes array col into separate rows, preserving null/empty arrays as a single null row.

Wrapper for pyspark.sql.functions.explode_outer.

flatten

flatten(col: Array[Array[T]]) -> Array[T]

Flattens a nested array col into a single-level array.

Wrapper for pyspark.sql.functions.flatten.

sequence

sequence(
    start: T, stop: T, step: T | None = None
) -> Array[T]

Generates an array of values from start to stop (inclusive), incrementing by step.

Wrapper for pyspark.sql.functions.sequence.

shuffle

shuffle(col: A) -> A

Returns a randomly shuffled copy of array col.

Wrapper for pyspark.sql.functions.shuffle.

size

size(col: Array) -> Int

Returns the number of elements in array col, or -1 for null.

Wrapper for pyspark.sql.functions.size.

slice

slice(
    col: A, start: Integer | int, length: Integer | int
) -> A

Returns a sub-array of col starting at start (1-based) with length elements.

Wrapper for pyspark.sql.functions.slice.

sort_array

sort_array(col: A, asc: bool = True) -> A

Returns array col sorted in ascending order by default; set asc=False for descending.

Wrapper for pyspark.sql.functions.sort_array.