snowflake.snowpark.functions.cast(column: Union[Column, str], to: Union[str, DataType]) Column[source]

Converts a value of one data type into another data type. The semantics of CAST are the same as the semantics of the corresponding to datatype conversion functions. If the cast is not possible, a SnowparkSQLException exception is thrown.


>>> from snowflake.snowpark.types import DecimalType, IntegerType
>>> df = session.create_dataframe([[1.5432]], schema=["d"])
>>>, DecimalType(15, 2)).as_("DECIMAL"), cast(df.d, IntegerType()).as_("INT")).show()
|"DECIMAL"  |"INT"  |
|1.54       |2      |