sql - Hadoop/Hive-将单行拆分为多行并存储到新表中

标签 sql hadoop hive sql-insert create-table

当前,我用这个主题解决了我的最初问题: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
谢谢
尼科

最佳答案

在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

关于sql - Hadoop/Hive-将单行拆分为多行并存储到新表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64700739/

相关文章:

c# - 在 NHibernate 中使用命名参数作为表名

sql - 用标识列重新插入行

hadoop - 在 Apache Spark 中使用 Reduce

java - 象鸟mvn包报错

java - Spring namedParameterJdbcTemplate 和一个列表参数 : how to check if it is null in SQL?

c# - 多次查找的推荐编程模式

Hadoop 一次读取多行

amazon-s3 - 子目录上的 S3 hive 外部表不起作用

hadoop - reducer 的数据分配不均

json - 使用 JsonSerDe 的 Hive 中的 ClassNotFoundException