没有合适的资源?快使用搜索试试~ 我知道了~
首页Hive那些事儿之八-大数据踩过的坑——Hive insert
Hive那些事儿之八-大数据踩过的坑——Hive insert
5星 · 超过95%的资源 20 下载量 102 浏览量
更新于2023-03-03
评论 1
收藏 31KB PDF 举报
Hive那些事儿之八-大数据踩过的坑——Hive insert 我在对Hive表数据清洗后,使用了如下SQL将结果集插入到新表中: insert into db_name.table_name_1 ( col_1,col2,col3 ) with temp_table_1 as ( select id,col_2 from db_name.table_name_2 where id = condatition ), temp_table_2 as ( select id,col_3 from db_name.table_name_3 where id = con
资源详情
资源评论
资源推荐
Hive那些事儿之八那些事儿之八-大数据踩过的坑大数据踩过的坑——Hive insert
Hive那些事儿之八-大数据踩过的坑——Hive insert
我在对Hive表数据清洗后,使用了如下SQL将结果集插入到新表中:
insert into db_name.table_name_1 (
col_1,col2,col3
)
with temp_table_1 as (
select id,col_2
from db_name.table_name_2 where id = condatition
),
temp_table_2 as (
select id,col_3
from db_name.table_name_3 where id = condatition
)
select a.id,a.col_2,b.col_3
from temp_table_1 a
left join temp_table_2 b on a.id= b.id
出现了如下报错信息:
Error while compiling statement: FAILED: ParseException line 15:0 cannot recognize input near ‘with’ ‘temp_table_1’ ‘as’ in
statement
错误原因:
Hive是支持with语法的,但是当与insert搭配使用时,语法与标准SQL语法规则不一样,需要将with放在insert之前,如下所
示:
with temp_table_1 as (
select id,col_2
f rom db_name.table_name_2 where id = condatition
),
temp_table_2 as (
select id,col3
from db_name.table_name_3 where id = condatition
)
insert into db_name.table_name_1 (
col_1,col2,col3
)
select a.id,a.col_2,b.col_3
from temp_table_1 a
left join temp_table_2 b on a.id= b.id
但是目标表db_name.table_name_1包含col_1,col_2,col_3,col_4,col_5等多个字段。上述insert语句执行后,又报了如下错
误:
Error while compiling statement: FAILED: NullPointerException null
错误原因:Hive SQL中的Insert不支持插入部分字段
解决方案:将字段补全,没有数据的字段插入空值,修改如下:
with temp_table_1 as (
select id,col_2
f rom db_name.table_name_2 where id = condatition
),
temp_table_2 as (
select id,col3
from db_name.table_name_3 where id = condatition
)
insert into db_name.table_name_1 (
col_1,col_2,col_3,col_4,col_5
)
select a.id,a.col_2,b.col_3,null,null
from temp_table_1 a
left join temp_table_2 b on a.id= b.id
作者:西西弗斯的石头
weixin_38631599
- 粉丝: 9
- 资源: 944
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 2023年中国辣条食品行业创新及消费需求洞察报告.pptx
- 2023年半导体行业20强品牌.pptx
- 2023年全球电力行业评论.pptx
- 2023年全球网络安全现状-劳动力资源和网络运营的全球发展新态势.pptx
- 毕业设计-基于单片机的液体密度检测系统设计.doc
- 家用清扫机器人设计.doc
- 基于VB+数据库SQL的教师信息管理系统设计与实现 计算机专业设计范文模板参考资料.pdf
- 官塘驿林场林防火(资源监管)“空天地人”四位一体监测系统方案.doc
- 基于专利语义表征的技术预见方法及其应用.docx
- 浅谈电子商务的现状及发展趋势学习总结.doc
- 基于单片机的智能仓库温湿度控制系统 (2).pdf
- 基于SSM框架知识产权管理系统 (2).pdf
- 9年终工作总结新年计划PPT模板.pptx
- Hytera海能达CH04L01 说明书.pdf
- 数据中心运维操作标准及流程.pdf
- 报告模板 -成本分析与报告培训之三.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论10