Failed to create table in HIVE reading CSV from HDFS

I'm having trouble creating a table in Hive while reading a CSV file from HDFS. Request below:

CREATE EXTERNAL TABLE testmail (memberId String , email String, sentdate String,actiontype String, actiondate String, campaignid String,campaignname String) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LOCATION '/user/hadoop/cloudera/ameeth/ca_email.csv'; 

Error receiving. Error in metadata:

MetaException (message: HDFS: // PC: 8020 / user / Hadoop / Cloudera / ameeth / ca_email.csv is not a directory or cannot create it)

Can anyone help me on this. Actually I want to run such elements in a .sql file as a job

+6
source share
3 answers

Hive collects all files in the directory specified by LOCATION. You do not need to specify a file name.

This should work:

 CREATE EXTERNAL TABLE testmail (memberId String , email String, sentdate String,actiontype String, actiondate String, campaignid String,campaignname String) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LOCATION '/user/hadoop/cloudera/ameeth'; 
+8
source

go to this way

find your metastore_db folder in cloudera and delete the * .lck files.

sudo rm / folder_path / metastore_db / * command. lck

0
source

Create a directory on HDFS and move the ca_email.csv file into it, then specify this directory as the LOCATION of your CREATE EXTERNAL TABLE command.

0
source

Source: https://habr.com/ru/post/975699/


All Articles