Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigQuery: 配列に対してFULL JOINを行う #47

Open
takegue opened this issue Nov 13, 2022 · 0 comments
Open

BigQuery: 配列に対してFULL JOINを行う #47

takegue opened this issue Nov 13, 2022 · 0 comments
Assignees

Comments

@takegue
Copy link
Owner

takegue commented Nov 13, 2022

unnestにおいてfull joinはエラーとなる

次のようなクエリはエラーとなる。

select  *
from unnest([1, 3]) as lhs
full join unnest([1,2]) as rhs

unnest() オペレーターは right join に対応していないため、 full join も記述できない

解決策

concatenateした配列を用意し、これに対して left joinすることで full joinと同じ出力を得ることができる。

select distinct 
  lhs, rhs 
from unnest([1,2] || [1, 3]) as both
left join unnest([1,2]) as lhs on both = lhs
left join unnest([1,3]) as rhs on both = rhs
@takegue takegue self-assigned this Nov 13, 2022
@takegue takegue changed the title 配列に対してFULL JOINを行う BigQuery: 配列に対してFULL JOINを行う Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant