在 Bigquery 中,如何将字符串的结构转换为列
因此,在表中,根据 Image 有 3 列,第三列是 Record(Struct),包含 2 个新旧结构。这些结构内部有列和值。
我可以通过这个 -change.old.name 访问每个最后一列,但我想将它们转换为普通列并用它创建另一个表?
尝试取消嵌套但不起作用,因为它不是数组。
更新:
终于排序了。应该通过选择所有嵌套数据来选择和转换所有列,并将别名设置为我们想要的方式或用下划线替换点。然后用它创建一个表。
create table abc
as
select
ID
,Created_on
,Change.old.add as Change_old_add
,Change.old.name as Change_old_name
,Change.old.count_people as Change_old_count_people
,Change.new.add as Change_new_add
,Change.new.name as Change_new_name
,Change.new.count_people as Change_new_count_people
FROM `project.Table`
So, In the table, there are 3 columns as per Image , 3rd one is Record(Struct), conntaing 2 structs old and new. Inside those structs there are columns and values.
I can access each final column by this -change.old.name , But I want to convert them as normal columns and create another taable with that ?
tried unnest but doesn't work as it's not array.
UPDATE :
Finally got it sorted. Should select and convert all columns by selecting all of the nested data and set the alias as how we want or replace dot with an underscore. Then create a table with that.
create table abc
as
select
ID
,Created_on
,Change.old.add as Change_old_add
,Change.old.name as Change_old_name
,Change.old.count_people as Change_old_count_people
,Change.new.add as Change_new_add
,Change.new.name as Change_new_name
,Change.new.count_people as Change_new_count_people
FROM `project.Table`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于整理好了。应该通过选择所有嵌套数据来选择和转换所有列,并将别名设置为我们想要的方式或用下划线替换点。然后用它创建一个表。
Finally got it sorted. Should select and convert all columns by selecting all of the nested data and set the alias as how we want or replace dot with an underscore. Then create a table with that.