Hive进行分区联接

问题描述 投票:0回答:1

我有这两个表:

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'离开2个表,但是将它们放在table_of_sale表的'country'分区上?

我有这两个表:表产品(product_id bigint,product_name字符串)按(product_category作为字符串)分区了表place_of_sale(product_id bigint,city字符串)按(...)分区了...

如果销售的产品是表place_of_sale中存在的产品,则使用LEFT JOIN:
select s.country, p.product_id, p.product_name, p.category, case when s.product_id is NULL then "not sold" else "sold" as sold from products p left join place_of_sale s on p.product_id = s.product_id order by country, product_id --order if necessary
join hive partition
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.