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

snowflake.snowpark.functions.to_decimal

snowflake.snowpark.functions.to_decimal(e: ColumnOrName, precision: int, scale: int) Column[source]

Converts an input expression to a decimal.

Example::
>>> df = session.create_dataframe(['12', '11.3', '-90.12345'], schema=['a'])
>>> df.select(to_decimal(col('a'), 38, 0).as_('ans')).collect()
[Row(ANS=12), Row(ANS=11), Row(ANS=-90)]
Copy
>>> df.select(to_decimal(col('a'), 38, 2).as_('ans')).collect()
[Row(ANS=Decimal('12.00')), Row(ANS=Decimal('11.30')), Row(ANS=Decimal('-90.12'))]
Copy