snowflake.snowpark.functions.div0¶
- snowflake.snowpark.functions.div0(dividend: Union[Column, str, int, float], divisor: Union[Column, str, int, float]) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.16.0/src/snowflake/snowpark/functions.py#L1678-L1701)¶
Performs division like the division operator (/), but returns 0 when the divisor is 0 (rather than reporting an error).
Example:
>>> df = session.create_dataframe([1], schema=["a"]) >>> df.select(div0(df["a"], 1).alias("divided_by_one"), div0(df["a"], 0).alias("divided_by_zero")).collect() [Row(DIVIDED_BY_ONE=Decimal('1.000000'), DIVIDED_BY_ZERO=Decimal('0.000000'))]