BigQuery UDF producing a correlated subquery error on execution

Below is for BigQuery Standard SQL

CREATE OR REPLACE FUNCTION `demo.test.getArrayFromString`(
  in_str STRING
  , in_reg_exp STRING
  , in_split_char STRING
  , in_stopword_type STRING) 
AS ((
  SELECT array_agg(DISTINCT words)
  FROM UNNEST(regexp_extract_all(in_str, in_reg_exp)) as words 
  WHERE NOT LOWER(words) IN UNNEST(ARRAY(
    SELECT LOWER(stop_word) 
    FROM `demo.test.stop_words`
    WHERE LOWER(stop_word_type) = LOWER(in_stopword_type)
  ))
));

if to use above UDF in your sample – output is

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top