snowflake.snowpark.functions.get¶

snowflake.snowpark.functions.get(col1: Union[Column, str, int], col2: Union[Column, str, int]) → Column[source]¶

Extracts a value from an object or array; returns NULL if either of the arguments is NULL.

Example:

>>> from snowflake.snowpark.functions import lit
>>> df = session.createDataFrame([({"a": 1.0, "b": 2.0}, [1, 2, 3],), ({}, [],)], ["map", "list"])
>>> df.select(get(df.list, 1).as_("idx1")).sort(col("idx1")).show()
----------
|"IDX1"  |
----------
|NULL    |
|2       |
----------


>>> df.select(get(df.map, lit("a")).as_("get_a")).sort(col("get_a")).show()
-----------
|"GET_A"  |
-----------
|NULL     |
|1        |
-----------
Copy