1

I've got an error when calling a UDF when the amount of data get increased:

Database Error in model test_model (models/prep/test_model.sql)
  100132 (P0000): JavaScript execution error: UDF execution time limit exceeded by function IMAGE_URL
  compiled SQL at target/run/models/test/test_model.sql

As mentioned in the documentation, there is a execution time limit for js UDF, so how long is the time limit and is it configurable?

AidenH
  • 11
  • 2
  • You're not giving us much context to help. You could contact support in case they can raise limits. Meanwhile here we can help with optimization if you can share more context. – Felipe Hoffa Jan 26 '22 at 04:57

2 Answers2

0

so lets write a function and use it to test this out.

CREATE OR REPLACE FUNCTION long_time(D DOUBLE)
      RETURNS variant
      LANGUAGE JAVASCRIPT
      AS $$
      function sleepFor(sleepDuration){
            var now = new Date().getTime();
            while(new Date().getTime() < now + sleepDuration){ 
                /* Do nothing */ 
            }
        }
      sleepFor(D*1000);
      return D;
      $$;
select long_time(1); -- takes 1.09s
select long_time(10); -- takes 10.32s
select long_time(60); -- Explodes with

JavaScript execution error: UDF execution time limit exceeded by function LONG_TIME

BUT, ran for 31.33s, so it seems you have 30 seconds to complete, which I feel is rather large amount of time, per call to me.

Simeon Pilgrim
  • 22,906
  • 3
  • 32
  • 45
0

The default timeout limit for JS UDFs is 30 seconds for a row set! Snowflake will send rows in sets to the JS engine, and it will try to process all rows in the set within that time. The size of the row set may vary, but you may assume it will be around 1K (this is just an estimation, the number of rows in a set could be much higher or lower).

The timeout limit is different for Java and Python UDFs. It's 300 seconds for them.

As @Felipe said, you may contact Snowflake Support and share your query ID to get help with this error. The Support may guide you to mitigate the issue.

Gokhan Atil
  • 9,278
  • 2
  • 11
  • 24