Skip to main content

elt

Returns the n-th input, e.g., returns input2 when n is 2. The function returns NULL if the index exceeds the length of the array and spark.sql.ansi.enabled is set to false. If spark.sql.ansi.enabled is set to true, it throws ArrayIndexOutOfBoundsException for invalid indices.

For the corresponding Databricks SQL function, see elt function.

Syntax

Python
from pyspark.databricks.sql import functions as dbf

dbf.elt(*inputs=<*inputs>)

Parameters

Parameter

Type

Description

inputs

pyspark.sql.Column or str

Input columns or strings.

Examples

Python
df = spark.createDataFrame([(1, "scala", "java")], ['a', 'b', 'c'])
df.select(elt(df.a, df.b, df.c).alias('r')).collect()
Output
[Row(r='scala')]