我有一个表 CLASS1,如下所示
hive> select * from class1;
OK
NULL student_name NULL NULL NULL
5 david 60 70 80
5 reena 55 40 80
7 joseph 66 75 89
Time taken: 0.659 seconds, Fetched: 4 row(s)
hive> desc class1;
OK
class tinyint
student_name varchar(30)
marks_english int
marks_maths int
marks_science int
Time taken: 0.553 seconds, Fetched: 5 row(s)
现在我想将以下格式的数据插入到新表中
Class name_marks
5 {david:[60,70,80]}
5 {reena:[55,40,80]}
7 {joseph:[66,75,89]}
有人能告诉我如何创建一个新表并以所需格式插入数据吗?
试试这个查询:
create table new_table as
select class
, MAP(student_name, ARRAY(marks_english, marks_maths, marks_science) as name_marks
from old_table;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句