I would like to implement the partitioned outer join in BigQuery. To give a concrete example, I'd like to achieve the partitioned outer join as the accepted answer here: https://dba.stackexchange.com/questions/227069/what-is-a-partitioned-outer-join
I understand there are a lot of discussions about this topic, but I can't make it work under BigQuery. I added partition by date after the left table following the same syntax in the answer as follows:
select * from (
select '2019-01-17' as date, 'London' as location, 11 as qty
union all
select '2019-01-15' as date, 'London' as location, 10 as qty
union all
select '2019-01-16' as date, 'Paris' as location, 20 as qty
union all
select '2019-01-17' as date, 'Boston' as location, 31 as qty
union all
select '2019-01-16' as date, 'Boston' as location, 30 as qty
) as sales partition by (date)
right join
(
select 'London' as location
union all
select 'Paris' as location
union all
select 'Boston' as location
)
as loc
using (location)
The target result I'm looking for is:
date qty location
15-JAN-19 NULL Boston
15-JAN-19 10 London
15-JAN-19 NULL Paris
16-JAN-19 30 Boston
16-JAN-19 NULL London
16-JAN-19 20 Paris
17-JAN-19 31 Boston
17-JAN-19 11 London
17-JAN-19 NULL Paris
But I got the following error: Syntax error: Unexpected keyword PARTITION at [11:12]
How can I implement it in BigQuery?