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.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L6848-L6875)

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