[Wranglers] NULL-safe GREATEST and LEAST now available in Snowflake
Ali, Saqib
docbook.xml at gmail.com
Thu Mar 28 13:43:49 UTC 2024
Snowflake now supports GREATEST_IGNORE_NULLS and LEAST_IGNORE_NULLS. In the
past if you used LEAST or GREATEST on a list of expressions that contained
NULL these functions always returned NULL, which was very problematic. You
had to do something like COALESCE(GREATEST(BILL_DATE, SHIP_DATE),
SHIP_DATE, BILL_DATE) to correctly handle NULLs. This was cumbersome. Now
you can simply use GREATEST_IGNORE_NULLS or LEAST_IGNORE_NULLS as following:
SQL Query:
select
order_number
, greatest_ignore_nulls(bill_date, ship_date)
as last_activity_date
from orders_fact;
More details at:
https://qosf.com/NULL-safe-greatest-and-least-in-Snowflake.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://analyticsengineering.net/pipermail/wranglers/attachments/20240328/6e9a1747/attachment.htm>
More information about the Wranglers
mailing list