我有两张table:
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\u id'在表place\u of seal的分区'country'上左键联接这两个表?
这是一个具有预期结果的示例:
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
这里的例子只给出了两个不同的国家,但想象很多不同的国家。这就像是为每个国家执行的左连接,然后是所有国家结果之间的联合。
1条答案
按热度按时间xdnvmnnf1#
如果销售的产品是表place of sale中的产品,则使用left join: