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

snowflake.snowpark.functions.div0

snowflake.snowpark.functions.div0(dividend: Union[Column, str, int, float], divisor: Union[Column, str, int, float]) Column[source]

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'))]
Copy