snowflake.snowpark.functions.explode_outer¶
- snowflake.snowpark.functions.explode_outer(col: Union[Column, str]) TableFunctionCall [source]¶
Flattens a given array or map type column into individual rows. Unlike
explode()
, if array or map is empty, null or empty, then null values are produced. The default column name for the output column in case of array input column isVALUE
, and isKEY
andVALUE
in case of map input column.- Parameters:
col – Column object or string name of the desired column
- Examples::
>>> df = session.create_dataframe([[1, [1, 2, 3], {"Ashi Garami": "Single Leg X"}], ... [2, [11, 22], {"Sankaku": "Triangle"}], ... [3, [], {}]], ... schema=["idx", "lists", "maps"]) >>> df.select(df.idx, explode_outer(df.lists)).sort(col("idx")).show() ------------------- |"IDX" |"VALUE" | ------------------- |1 |1 | |1 |2 | |1 |3 | |2 |11 | |2 |22 | |3 |NULL | -------------------
>>> df.select(df.idx, explode_outer(df.maps)).sort(col("idx")).show() ---------------------------------------- |"IDX" |"KEY" |"VALUE" | ---------------------------------------- |1 |Ashi Garami |"Single Leg X" | |2 |Sankaku |"Triangle" | |3 |NULL |NULL | ----------------------------------------
See also