我发现以下现象:
我有一个BQ查询,其中包含使用REGEXP_EXTRACT函数提取的100个字段。
我添加了一个新表达式并得到以下错误:无法解析正则表达式"":模式太大 - 编译失败。
单独查询此表达式时,一切运行正常,在较大的查询中,我收到错误。
这是基于github示例数据和简单正则表达式的问题的副本:
SELECT repository.description,
REGEXP_EXTRACT(repository.description,r'(?:\w){0}(\w)') as Pos1,
REGEXP_EXTRACT(repository.description,r'(?:\w){1}(\w)') as Pos2,
REGEXP_EXTRACT(repository.description,r'(?:\w){2}(\w)') as Pos3,
.
. here it goes on and on in the same pattern
.
REGEXP_EXTRACT(repository.description,r'(?:\w){198}(\w)') as Pos199,
REGEXP_EXTRACT(repository.description,r'(?:\w){199}(\w)') as Pos200,
REGEXP_EXTRACT(repository.description,r'(?:\w){200}(\w)') as Pos201,
FROM [publicdata:samples.github_nested] LIMIT 1000
它返回:
Failed to parse regular expression "(?:\w){162}(\w)": pattern too large - compile failed
但在跑步时:
SELECT repository.description,
REGEXP_EXTRACT(repository.description,r'(?:\w){162}(\w)') as Pos163,
FROM [publicdata:samples.github_nested] LIMIT 1000
一切都运行正常......
可以在单个查询中使用的REGEXP_EXTRACT的#或其组合复杂性是否有限制?
答案 0 :(得分:0)
我会调查这个问题。作为一种解决方法,看起来你正在尝试做的是将字段分成每个字符位置的单独字段...所以转向" abc"进入{pos1:" a",pos2:" b",pos3:" c"}。那是对的吗?如果是这样,您可能想尝试LEFT()和RIGHT()函数。如在
LEFT(1, reponsitory.description) as pos1,
RIGHT(1, LEFT(2, reponsitory.description)) as pos2,
RIGHT(1, LEFT(3, reponsitory.description)) as pos3.
这应该比编译200个正则表达式使用更少的资源(尽管它仍然不太可能很快)。