本文介绍了bigquery中的REGEXP_CONTAINS订单和Case语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是case语句和REGEXP_CONTAINS.只是想看看下面的命令是否可以给我正确的输出.
I'm using case statement and REGEXP_CONTAINS.Just wanted to see if the following order will give me the correct output.
(CASE
WHEN REGEXP_CONTAINS(AdSet, '(?i)BUS') THEN "BUS"
WHEN REGEXP_CONTAINS(AdSet, '(?i)BRA') THEN "BR"
WHEN REGEXP_CONTAINS(AdSet, '(?i)DIG') THEN "TR"
WHEN REGEXP_CONTAINS(AdSet, '(?i)INS') THEN "INS"
WHEN REGEXP_CONTAINS(AdSet, '(?i)INV') THEN "INV"
WHEN REGEXP_CONTAINS(AdSet, '(?i)SAV') THEN "SAV"
WHEN REGEXP_CONTAINS(AdSet, '(?i)TRA') THEN "TR"
WHEN REGEXP_CONTAINS(AdSet, '(?i)CC') THEN "CC"
WHEN REGEXP_CONTAINS(AdSet, '(?i)HL') THEN "HL"
WHEN REGEXP_CONTAINS(AdSet, '(?i)BR') THEN "BR"
END) as pf
推荐答案
如果您希望对关键字进行不区分大小写的搜索,似乎是正确的,而通常,字符串函数比REGEX函数更有效,请考虑:
Seems correct if you want case insensitive search for the keyword, while in general, string functions are more efficient than REGEX functions, consider to:
REGEXP_CONTAINS(AdSet, '(?i)BUS') THEN "BUS"
=>
STRPOS(UPPER(AdSet), 'BUS') <> 0 THEN "BUS"
这篇关于bigquery中的REGEXP_CONTAINS订单和Case语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!