hadoop/hive-将一行拆分为多行并存储到新表

92vpleto  于 2021-05-27  发布在  Hadoop
关注(0)|答案(1)|浏览(502)

目前,我解决了这个主题的初始问题:hadoop/hive—将一行拆分为多行并存储到一个新表中。
有人知道如何用分组的sub创建一个新表吗?

  1. ID Subs
  2. 1 deep-learning, machine-learning, python
  3. 2 java, c++, python, javascript

通过下面的代码,我得到了我正在寻找的返回值,但无法找出如何将输出保存到新表中

  1. use demoDB
  2. Select id_main , topic_tag from demoTable
  3. lateral view explode (split(topic_tag , ',')) topic_tag as topic

谢谢尼科

fkvaft9z

fkvaft9z1#

在 hive 里,你可以用 create ... as select ... :

  1. create table newtable as
  2. select id_main, topic_tag
  3. from demoTable
  4. lateral view explode (split(topic_tag , ',')) topic_tag as topic

这将创建一个新表,并从查询的结果集启动其内容。如果新表已经存在,则使用 insert ... select 取而代之的是:

  1. insert into newtable (id_main, topic_tag)
  2. select id_main, topic_tag
  3. from demoTable
  4. lateral view explode (split(topic_tag , ',')) topic_tag as topic

相关问题