gpt4 book ai didi

javascript - BigQuery UDF 和 String.prototype.indexOf()

转载 作者:行者123 更新时间:2023-12-03 07:22:54 25 4
gpt4 key购买 nike

我正在尝试使用 String.prototype.indexOf()在 BigQuery UDF 中检查一个字符串是否包含另一个字符串,即使用基本 JavaScript。

但它给了我这个错误:

enter image description here

我做错了什么?

最佳答案

我没有考虑到 BigQuery 中的传入表行可能具有 null 值。

只需检查s即可轻松修复:

function decodeHelper(s) {
if(s){
if(s.indexOf("foo") > -1){
return "true";
}else{
return "false";
}
}
}

关于javascript - BigQuery UDF 和 String.prototype.indexOf(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36127743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com