当前,我用以下主题解决了我的第一个问题:Hadoop / Hive-将单行拆分为多行并存储到新表中。
有人知道如何用分组的子表创建新表吗?
ID Subs
1 deep-learning, machine-learning, python
2 java, c++, python, javascript
使用下面的代码,我可以得到想要的回报,但无法弄清楚如何将输出保存到新表中
use demoDB
Select id_main , topic_tag from demoTable
lateral view explode (split(topic_tag , ',')) topic_tag as topic
谢谢 尼科
答案 0 :(得分:0)
在Hive中,您可以使用create ... as select ...
:
create table newtable as
select id_main, topic_tag
from demoTable
lateral view explode (split(topic_tag , ',')) topic_tag as topic
这将创建一个新表,并从查询的结果集中初始化其内容。如果新表已存在,请改用insert ... select
:
insert into newtable (id_main, topic_tag)
select id_main, topic_tag
from demoTable
lateral view explode (split(topic_tag , ',')) topic_tag as topic