我有这两个表:
table products
(
product_id bigint,product_name string
)
partitioned by (product_category as string)
table place_of_sale
(
product_id bigint,city string
)
partitioned by (country as string)
如何基于“ product_id”离开两个表,但将其放置在表place_of_sale的分区“国家”上?
这是一个预期结果的示例:
table products
product_id product_name product_category
1000 banana fruit
1001 coconut fruit
1002 ananas fruit
2002 cow animal
2003 beef animal
table place_of_sale
product_id city country
1000 Texas USA
1002 Miami USA
2003 Sydney Australia
desired result for a left join between table products and table place_of_sale over the partition country :
product_id product_name product_category city country
1000 banana fruit Texas USA
1001 coconut fruit null null
1002 ananas fruit Miam USA
2002 cow animal null null
2003 beef animal Sydney Australia
在此示例中仅给出了两个不同的国家,但可以想象有很多不同的国家。 这就像在每个国家/地区执行左联接,然后在所有国家/地区的结果之间进行联合一样。