我们如何处理BigQuery功能的异常?
给定任何功能,例如:
CREATE FUNCTION ds.fn(param ANY TYPE) RETURNS STRING AS (
(SELECT 1/0)
);
当语句失败并返回默认值时,是否有办法处理错误?
注意:我的问题是关于的任何错误,选择语句可以投掷,而不仅仅是上面示例中的算术。
given any function like e.g:
CREATE FUNCTION ds.fn(param ANY TYPE) RETURNS STRING AS (
(SELECT 1/0)
);
Is there a way for handling errors when the statement fails and return a default value?
Note: My question is about any error that a select statement can throw and not only the arithmetic in the example above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用UDF中的安全功能使功能更强大,并且如果它失败如下,也可以使其返回默认值。
另外,您可以使用
begin ...异常
block:You can make your function more robust using SAFE functions inside a UDF and also make it return default value if it fails like below.
Also, you can catch a error in a BigQuery script using
BEGIN...EXCEPTION
block: