Created 02-01-2016 10:33 PM
My first step was to create an ORC table on Hive with the same schema as the one imported on hdp :
CREATE TABLE IF NOT EXISTS orcemployees( emp_no int, birth_date date, first_name string, last_name string, gender string, hire_date date) STORED AS ORC;
My second step was to copy the data from employees into orcemployees:
insert into table orcemployees select * from employees;
The problem is when I execute select * from orcemployees; the schema is displayed and not the associated data.
Created 02-02-2016 03:13 PM
your error says you don't have permissions for admin user on that folder. You need to
sudo -u hdfs hdfs dfs -chown -R admin:hdfs /tmp/task/employees
OR
sudo -u hdfs hdfs dfs -chmod -R 777 /tmp/task/employees
Created 02-02-2016 12:02 AM
ok @Ancil McBarnett -- Thanks for your ideas. I was able to do a sqoop import of the tables using --hive-import onto hive and then I created a orc table. Is there anyway I can access these imported files on hive? Because I'm able to find the files I imported on hdp but not hive. hdfs-imported-tables.png
Created 02-02-2016 12:06 AM
Create table pointing to this directory and query in the Ambari Hive view @keerthana gajarajakumar
Created 02-02-2016 12:20 AM
@Artem Ervits -- Thanks. Any suggestions how I can do it? because I was unable to read from this location with the code I wrote.
Created 02-02-2016 03:10 PM
@Ancil McBarnett & @Artem Ervits -- Thanks a lot for taking the time to reply. I tried creating an external table to point to the hdfs location I'm getting the following error (please find the image below). Besides, I entered these lines randomly .. FIELDS TERMINATED BY '\t' STORED AS TEXTFILE. I'm not sure if it's tab separated nor saved as a text file. How can I view the mysql tables imported into hive or hdfs?? I'm unable to open it.
Created 02-02-2016 12:23 AM
I assume this is a completely different question right as you are able to view the hive table since you used the --hive-import
Sqoop option, and you are now able to see the ORC table you created subsequently and query the data after accomplishing an "INSERT OVERWRITE TABLE" right?
If you are just asking how can I import an existing HDFS file/ folder into a Hive Table, then @Artem Ervits is correct. Just do for example create external table employee2 LOCATION '/tmp/task/employees' and query using Hive view. For syntax see
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL
Created 02-02-2016 12:44 AM
CREATE EXTERNAL TABLE tweets ( |
createddate string, |
geolocation string, |
tweetmessage string, |
`user` struct<geoenabled:boolean, id:int, name:string, screenname:string, userlocation:string>) |
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' |
LOCATION '/user/root/'; |
Created 02-01-2016 11:05 PM
You can also review the docs here:
Created 02-01-2016 11:20 PM
I reviewed these links. I can follow those steps if my data has been imported to hdp and I want to create an orctable in hive. But what you're suggesting is to import the data on hive and then create an orc table.
Created 02-02-2016 03:13 PM
your error says you don't have permissions for admin user on that folder. You need to
sudo -u hdfs hdfs dfs -chown -R admin:hdfs /tmp/task/employees
OR
sudo -u hdfs hdfs dfs -chmod -R 777 /tmp/task/employees
Created 02-02-2016 03:51 PM
@Artem Ervits - I was able to execute the query for external table creation.. thanks:)