Snowflake’s ACCUMULATE function lets users create custom aggregate functions entirely in standard SQL. It uses four SQL lambda steps—initialize, accumulate, combine, and terminate—to define how data is processed and produce a final result. This makes it possible to build specialized calculations, such as products and geometric means, without relying on Python, JavaScript, or external code. The approach also supports flexible and scalable aggregation for complex use cases.
http://quettabyte.net/gist.php?id=jnvj9