【发布时间】:2019-11-05 20:10:19
【问题描述】:
我有这两张桌子:
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的分区“国家”的2个表?
这是一个具有预期结果的示例:
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
这里仅给出了 2 个不同国家的示例,但可以想象有很多不同的国家。 这就像为每个国家/地区执行左连接,然后在所有国家/地区的结果之间进行联合。
【问题讨论】:
-
你想要什么结果。在这种情况下,不清楚“在分区‘国家’之上”是什么意思
-
我想拥有每个国家/地区的已售和未售产品列表
-
请提供一些例子,不清楚“列表”是什么意思。每个国家/产品或数组的分隔符分隔字符串,或者您只需要每个产品一行。未售出表示第二张表中没有产品?
标签: join hive hiveql partition