snowflake.snowpark.functions.try_to_decfloat

snowflake.snowpark.functions.try_to_decfloat(e: Union[Column, str], fmt: Optional[Union[Column, str]] = None) → Column[source]

A special version of TO_DECFLOAT that returns NULL instead of raising an error if the conversion cannot be performed. Unlike the other TRY_TO_* functions, TRY_TO_DECFLOAT also accepts numeric and boolean input.

Example:

>>> df = session.create_dataframe(['12', '-90.12345', 'abc'], schema=['a'])
>>> df.select(try_to_decfloat(col('a')).as_('ans')).collect()
[Row(ANS=Decimal('12')), Row(ANS=Decimal('-90.12345')), Row(ANS=None)]