You are viewing documentation about an older version (1.9.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]¶

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