Skip to content
Advertisement

UDF JavaScript implementation into Snowflake

I found usefull JS function that I want to implement into snowflake’s UDF in order to move complex computation to the dwh.

http://trentrichardson.com/2010/04/06/compute-linear-regressions-in-javascript/

Attempt to rework above as SQL procedure:

Execution fails with error: SQL compilation error: Invalid identifier which is odd since procedure has been created.

Advertisement

Answer

You’re almost there. To pass an array, try using ARRAY_CONSTRUCT or PARSE_JSON, like so:

To get the code working, make it a FUNCTION that returns OBJECT, and be sure to actually invoke linearRegression() from within your UDF:

Hope that’s helpful.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement