I'm trying to use String.prototype.indexOf() in a BigQuery UDF to check if one String contains another ie use basic JavaScript.
But it gives me this error:
What am I doing wrong?
I didn't take into consideration that my incoming table row in BigQuery might have null
values.
Easy fix by just checking s
:
function decodeHelper(s) {
if(s){
if(s.indexOf("foo") > -1){
return "true";
}else{
return "false";
}
}
}
Depends on how you then deal with result of decodeHelper, you might consider below option
function decodeHelper(s) {
if(s){
if(s.indexOf("b") > -1){
return "true";
}else{
return "false";
}
}else{
return "false";
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.