You are viewing documentation about an older version (1.16.0). View latest version

snowflake.snowpark.functions.object_construct_keep_null

snowflake.snowpark.functions.object_construct_keep_null(*key_values: Union[Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L5628-L5653)

Returns an object containing the contents of the input (i.e. source) object with one or more keys removed.

Example:

>>> from snowflake.snowpark.types import StructType, StructField, VariantType, StringType
>>> df = session.create_dataframe(
...     [["key_1", "one"], ["key_2", None]],
...     schema=StructType([StructField("k", StringType()), StructField("v", VariantType())])
... )
>>> df.select(object_construct_keep_null(col("k"), col("v")).alias("result")).show()
--------------------
|"RESULT"          |
--------------------
|{                 |
|  "key_1": "one"  |
|}                 |
|{                 |
|  "key_2": null   |
|}                 |
--------------------
Copy
Language: English