pyspark.sql.tvf.TableValuedFunction.inline_outer#

TableValuedFunction.inline_outer(input)[source]#

Explodes an array of structs into a table. Unlike inline, if the array is null or empty then null is produced for each nested column.

Added in version 4.0.0.

Parameters:
inputColumn

input column of values to explode.

Returns:
DataFrame

Examples

>>> import pyspark.sql.functions as sf
>>> spark.tvf.inline_outer(sf.array(
...     sf.named_struct(sf.lit("a"), sf.lit(1), sf.lit("b"), sf.lit(2)),
...     sf.named_struct(sf.lit("a"), sf.lit(3), sf.lit("b"), sf.lit(4))
... )).show()
+---+---+
|  a|  b|
+---+---+
|  1|  2|
|  3|  4|
+---+---+
>>> spark.tvf.inline_outer(sf.array().astype("array<struct<a:int,b:int>>")).show()
+----+----+
|   a|   b|
+----+----+
|NULL|NULL|
+----+----+