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

snowflake.snowpark.functions.object_construct

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

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
Language: English