我创建了一个永久 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
[1:15] 处的 .udf_library.is_valid_email
如果我将它创建为临时函数,它确实有效,但这违背了拥有永久 UDF 的全部目的
有任何想法吗?
谢谢