hadoop - 使用查找表将数据插入 Hive 表
问题描述
有人可以在这种情况下帮助我吗?
如何通过从其他 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;
让我知道这是否有帮助!
推荐阅读
- sql-server - 为数据库中的所有表创建删除列的视图
- shell - Buildroot 通用包未安装在 init.d 目录中
- java - Ajax post 调用应该返回到 html 页面
- promql - PromqQL 中的 label:metric:function 是什么?
- javascript - 不使用 Regex 而是循环搜索和替换字符串,如何一次替换多个单词?
- gradle - 如何使用自定义任务作为工件
- python - 使用 python pyodbc 连接到 Docker 容器中的 Sybase 数据库的 utf-8 编码问题
- c# - Win 表单中标签或文本框的 C# 计数
- maven - 将 OptaPlanner 导出为 jar 时出现 ExceptionInInitializerError
- regex - 正则表达式替换方括号之间的字符,但不替换括号之间的字符