I have a BQ table that has a column of type RECORD
that looks like this:
tags
|_ sub_tags
When I do:
SELECT tags.sub_tags FROM `MY_TABLE`
I get this:
Row | sub_tags.array_element |
---|---|
1 | :something |
:something_else | |
what::the:hell | |
2 | more_stuff |
3 | and_more_stuff |
How do I get the value or check if :something
exists in the STRUCT
?
See if these solutions help: given that you have a struct in your source table with tags.sub_tags.
WITH yourTable AS (
SELECT struct(['one', 'two','three'] AS sub_tags) as tags
union all
SELECT struct(['one', 'four','three'] AS sub_tags) as tags
)
SELECT * FROM `yourTable`
where 'two' in unnest(tags.sub_tags)
SELECT * except(value) FROM `yourTable`, unnest(tags.sub_tags) as value
where value = 'two'
These are some good reference for arrays: https://cloud.google.com/bigquery/docs/reference/standard-sql/arrays
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.