gpt4 book ai didi

hadoop - 使用查找表将数据插入Hive表

转载 作者:行者123 更新时间:2023-12-02 22:02:44 26 4
gpt4 key购买 nike

在这种情况下有人可以帮我吗?

如何通过从其他Hive表中查找值将数据插入Hive表中?

我的input_source表如下所示:

date    key  lines  type
29-May 1 A A16
29-May 2 B D44
29-May 3 C K90
29-May 4 A L90
29-May 5 A J76
29-May 6 B Y78

我对上述每种类型都有详细的描述。
例如:
A and A16 is "Excellet"
B and D44 is "Average"
A and L90 is "Good"
B and Y78 is "Fair"

等等..

在将数据插入结果表的过程中,我需要阅读以下行并键入并将描述插入最终表中,如下所示:
date    key   desc
29-May 1 Excellent
29-May 2 Average
29-May 3 Not bad
29-may 4 Good
29-May 5 Fine
29-may 6 Fair

您能否建议实现这一目标?

最佳答案

使用加入。这可能是需要的。

insert overwrite table target_table
select date,key,descrip
from
(
select a.date,a.key,a.lines, a.type,b.descrip from
input_source a
join
description_table b
on a.lines = b.lines and a.type = b.type
)
t;

让我知道这是否有帮助!

关于hadoop - 使用查找表将数据插入Hive表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50593356/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com