Hive 从现有表中创建具有复杂类型的新表

Posted

技术标签:

【中文标题】Hive 从现有表中创建具有复杂类型的新表【英文标题】:Hive create new table having complex types from an existing table 【发布时间】:2017-01-23 11:33:35 【问题描述】:

给定一个 Hive 表

create table movie_1(id int, movie_title string, actor string, gender string)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ';'  

vi movies.txt 
1;hero;john penn;male 
2;hero;maggie mcguirre;female 
3;lost;peter jones;male

假设一个新表movie_2,但字段类型为STRUCT

create table movie_2(id int, movie_title string, STRUCT <actor:string, gender:string>) 

如何从现有表movie_1 中创建一个新表movie_2,即从movies_1 中选择插入新表movies_2?

【问题讨论】:

【参考方案1】:

检查此link。在这种情况下,您可以使用 to_map UDF 来创建具有复杂数据类型的新表。

【讨论】:

以上是关于Hive 从现有表中创建具有复杂类型的新表的主要内容,如果未能解决你的问题,请参考以下文章