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

snowflake.snowpark.functions.to_object

snowflake.snowpark.functions.to_object(e: Union[Column, str]) Column[source]

Converts any value to a OBJECT value or NULL (if input is NULL).

Example::
>>> from snowflake.snowpark.types import VariantType, StructField, StructType
>>> from snowflake.snowpark import Row
>>> schema = StructType([StructField("a", VariantType())])
>>> df = session.create_dataframe(["{'a':10,'b':20}", None], schema=schema)
>>> df.select(to_object(col("a")).as_('ans')).collect()
[Row(ANS='{\n  "a": 10,\n  "b": 20\n}'), Row(ANS=None)]
Copy