【问题标题】:User Defined Function not found未找到用户定义的函数
【发布时间】:2020-11-17 02:08:29
【问题描述】:

我创建了一个永久 UDF 函数来验证这样的电子邮件:

create or replace function 
`project-name`.udf_library.is_valid_email(text STRING)
returns Bool
as (REGEXP_CONTAINS(text, r"valid_regex"));

并使用以下查询对其进行了测试,效果非常好:

with emails as
(select 'alberto@example.com' as email
union all
select 'foobar' as email
union all
select 'disposable.style.email.with+symbol@example.com' as email
union all
select '"john..doe"@example.org' as email
union all
select 'i_like_underscore@but_its_not_allow_in_this_part.example.com' as email)
select email, `project-name`.udf_library.is_valid_email(email) as validEmail from emails
Row email                                                   validEmail 
1   alberto@example.com                                           true
2   foobar                                                       false
3   disposable.style.email.with+symbol@example.com                true
4   "john..doe"@example.org                                       true
5   i_like_underscore@but_its_not_allow_in_this_part.example.com false

但是当我查询一个表并尝试使用这样的函数时

SELECT email, `project-name`.udf_library.is_valid_email(email) as validEmail 
FROM `project-name.Mydataset.MyTable`

我明白了:

未找到函数:project-name.udf_library.is_valid_email 在 [1:15]

如果我将它创建为临时函数,它确实有效,但这违背了拥有永久 UDF 的全部目的

有什么想法吗?

谢谢

【问题讨论】:

    标签: google-bigquery bigquery-udf


    【解决方案1】:

    请检查数据集 project-name.Mydatasetproject-name.udf_library 的位置,它们必须位于同一区域,您的最后一个查询才能正常工作。

    使用WITH 准备数据的查询有效,因为它被路由到UDF 所在的区域。最后一个查询可能被路由到数据所在的位置。

    【讨论】:

    • 你是对的 - 我在美国地区错误地创建了我的数据集。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-04
    • 1970-01-01
    • 2015-02-15
    相关资源
    最近更新 更多