本文介绍了如何将键值对加载到配置单元表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下是我的数据集:
Jun name =balajiid = 101
Mar name =kumarid = 102
创建表格:
create table示例(月份字符串,名称字符串,id int)
以'space'结尾的行格式分隔字段由'='终止的地图键;
结果:
select * from sample;
JUN name =balajiNULL
Mar name =kumarNULL
预期结果:
JUN balaji 101
Mar kumar 102
请帮我解决这个问题。
解决方案
create table sample(mnth string,names map< string,string>,ids map< string ,int>)
由格式分隔的字段以''结尾的映射键终止';';
选择查询应该是:
从sample中选择mnth,names [name],id [id];
结果:
Junbalaji101
Markumar102
如果您从示例中触发
选择*
:
Jun {name:\balaji \} {id:101}
Mar {name:\kumar \} {id: 102}
要访问map中的每个值,您需要像
name]
。Below is my data set:
Jun name="balaji" id=101 Mar name="kumar" id=102
Created table:
create table sample(month string,name string, id int) row format delimited fields terminated by 'space' map keys terminated by '=';
Result:
select * from sample; JUN name="balaji" NULL Mar name="kumar" NULL
Expected result:
JUN balaji 101 Mar kumar 102
Please help me on this.
解决方案Create tables like this:
create table sample(mnth string,names map<string,string>,ids map<string,int>) row format delimited fields terminated by ' ' map keys terminated by '=';
Select query should be:
select mnth,names["name"],ids["id"] from sample; result: Jun "balaji" 101 Mar "kumar" 102
If you fire
select *
from sample:Jun {"name":"\"balaji\""} {"id":101} Mar {"name":"\"kumar\""} {"id":102}
For accessing each value in map you need to pass like
names["name"]
.这篇关于如何将键值对加载到配置单元表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!