1

I am new for hadoop and big data concepts. I am using Hortonworks sandbox and trying to manipulate values of a csv file. 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. SQL LIKE query could be something like this:

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. Please help me to fine the solution,I really need to it. Thanks in advance.

Alexander Gessler
  • 45,603
  • 7
  • 82
  • 122
  • Please give the structure of **table1** and **table2** first. – Mukesh S Jul 14 '14 at 12:24
  • CREATE TABLE table1(userid STRING, name STRING, graduated STRING) and CREATE TABLE table2(userid STRING, name STRING, graduated BINARY) In fact, I want to convert some values to Binary and insert them into new table. – user3836445 Jul 14 '14 at 21:06

1 Answers1

1

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.

Alexander Gessler
  • 45,603
  • 7
  • 82
  • 122
  • Sorry @Alexander but your Hive query is in correct. It should be : **CREATE TABLE table1 as SELECT id, name, graduated FROM table2 WHERE university = 'aaa'** – Mukesh S Jul 14 '14 at 12:26
  • Thanks guys, but I want to insert an specific values. For example instead of graduated values I want to insert 0 or 1. The CREATE script just imports data from another tables and does not let to change values. – user3836445 Jul 14 '14 at 20:53