Deduplikat String Delimited BigQuery

CREATE OR REPLACE FUNCTION `project.dataset.delim_dedupe`(delim_str STRING, splitter STRING) RETURNS STRING LANGUAGE js
OPTIONS (description="Dedupes delimited string list.") AS R"""
if (delim_str == null){
    var deduped = null;
    return(deduped)} else {

      var arr = delim_str.split(splitter);
      
      var deduped = [...new Set(arr)]};

    return(deduped.join(splitter))
""";
CheneyPinata