pyspark.sql.functions.map_entries

pyspark.sql.functions.map_entries(col: ColumnOrName) → pyspark.sql.column.Column[source]

Collection function: Returns an unordered array of all entries in the given map.

New in version 3.0.0.

Parameters
colColumn or str

name of column or expression

Examples

>>> from pyspark.sql.functions import map_entries
>>> df = spark.sql("SELECT map(1, 'a', 2, 'b') as data")
>>> df.select(map_entries("data").alias("entries")).show()
+----------------+
|         entries|
+----------------+
|[{1, a}, {2, b}]|
+----------------+