简体   繁体   English

如何使用Hive,Pig或MapReduce“插入值”?

[英]How to “insert into values” using Hive,Pig or MapReduce?

I am new for hadoop and big data concepts. 我是Hadoop和大数据概念的新手。 I am using Hortonworks sandbox and trying to manipulate values of a csv file. 我正在使用Hortonworks沙箱,并尝试操纵csv文件的值。 So I imported the file using file browser and created a table in hive to do some query. 因此,我使用文件浏览器导入了文件,并在蜂巢中创建了一个表以进行一些查询。 Actually I want to have an "insert into values" query to select some rows, change the value of columns(for example change string to binary 0 or 1) and insert it into a new table. 实际上,我想使用“插入值”查询来选择一些行,更改列的值(例如,将字符串更改为二进制0或1),然后将其插入到新表中。 SQL LIKE query could be something like this: SQL LIKE查询可能是这样的:

Insert into table1 (id, name, '01')
select id, name, graduated
from table2
where university = 'aaa'

Unfortunately hive could not insert (constant) values (without importing from file) and I don`t know how to solve this problem using hive,pig or even mapreduce scripts. 不幸的是,hive无法插入(常量)值(不从文件导入),而且我不知道如何使用hive,pig甚至mapreduce脚本解决此问题。 Please help me to fine the solution,I really need to it. 请帮助我完善解决方案,我确实需要它。 Thanks in advance. 提前致谢。

In Hive, 在蜂巢中

 CREATE TABLE table1 as SELECT id, name, graduated FROM table2
    WHERE university = 'aaa'

should create a new table with the results of the query. 应该使用查询结果创建一个新表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM