简体   繁体   English

如何在 Bigquery 中将字符串拆分为带空格分隔符的行?

[英]How to split string into rows with space delimiter in Bigquery?

I'm having a hard time understanding regular expression.我很难理解正则表达式。

I have a table mydataset.city我有一张表 mydataset.city

id | city
---+----------------------------------------------    
1  | LOS ANGELES     NEW YORK     INDIANAPOLIS

Between each cities contain 5 spaces as delimiter.每个城市之间包含 5 个空格作为分隔符。

And I want it to split them into rows like this:我希望它将它们分成这样的行:

id | city
---+------------
1  | LOS ANGELES
1  | NEW YORK
1  | INDIANAPOLIS

How can I write this in bigquery?我怎样才能在 bigquery 中写这个?

Use below在下面使用

select id, city
from your_table, unnest(split(city, '     ')) city    

if applied to sample data in your question - output is如果应用于您问题中的示例数据 - output 是

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM