I'm converting a data warehouse front-end from a Hadoop back-end to a Snowflake back-end and I need to convert each of its SQL functions to the Snowflake equivalent. One thing I'm having trouble with is handling formulas that produce Infinity/-Infinity or NaN (Not A Number).
In Hadoop, this was a simple matter of checking the formula using IS_INF and IS_NAN. In SQL Server (another back-end we tested), this can be done using SET ARITHABORT OFF/SET ANSI_WARNINGS OFF. The Hadoop method adds additional logic checks to the SQL and the SQL Server method just straight up ignores the errors and returns NULLs instead of throwing an error. I prefer the latter method because it doesn't slow down the queries, but I'm open to any method that will actually work in Snowflake because up to this point I can't find one.
I should note that there are Snowflake Functions that help avoid very specific errors, such as divide by zero (i.e. DIV0 function or NULLIF), but that doesn't help me for two reasons. First, that only takes care of certain issues (div by zero). I need something that will handle any formula that produces Inf/NaN. Second, the formulas in question are often written by end users in the front-end, which means I don't know which part of the formula is the dividend and which is the divisor. The formula could be very complex (including CASE WHEN or other Functions or any number of things), so parsing out the divisor (so I can use NULLIF), or parsing out both the dividend and the divisor (so I can use DIV0) isn't really an option.
I noticed documentation for Snowflake which said that the FLOAT Data Type could handle special values like Infinity and NaN, but I don't see any way to actually produce those values in a formula without throwing an error.
Any help would be appreciated.