Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

deduplicate delimited string 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))
""";
 
PREVIOUS NEXT
Tagged: #deduplicate #delimited #string #bigquery
ADD COMMENT
Topic
Name
1+3 =