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

snowflake.snowpark.functions.object_construct¶

snowflake.snowpark.functions.object_construct(*key_values: Union[Column, str]) → Column[source]¶

Returns an OBJECT constructed from the arguments.

Example:

>>> from snowflake.snowpark.types import StructType, StructField, VariantType, StringType
>>> df = session.create_dataframe(
...     [["name", "Joe"], ["zip", "98004"],["age", None], [None, "value"]],
...     schema=StructType([StructField("k", StringType()), StructField("v", VariantType())])
... )
>>> df.select(object_construct(col("k"), col("v")).alias("result")).show()
--------------------
|"RESULT"          |
--------------------
|{                 |
|  "name": "Joe"   |
|}                 |
|{                 |
|  "zip": "98004"  |
|}                 |
|{}                |
|{}                |
--------------------
Copy