snowflake.snowpark.functions.to_object¶
- snowflake.snowpark.functions.to_object(e: Union[Column, str]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L7691-L7704)¶
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)]