2
votes

So basically I would like to create a table containing csv files

I tried something like this where the filenames only differ from eachother by the two last digits :

CREATE EXTERNAL TABLE pageviews (page_date string,site string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' STORED AS TEXTFILE LOCATION '/user/hue/201401/pageviews/supersite_1046_201401**.csv';

To me this syntax looks ok but when I execute it I get the following:

Error occurred executing hive query: Unknown exception.

Any help would be appreciated.

1
I doubt if it can accept wildcards in textfile location.Suvarna Pattayil
That is indeed one of my points of concern but I have no clue how to do it without using a wildcard.user3419138
This is a suggestion. Can you try providing path only upto the folder name (Assuming the folder will contain only the necessary files).Suvarna Pattayil
it does indeed only contain the necessary files yet I get the same unknown exception error. To give u an idea the folder contains out of 17 identical constructed csv files.user3419138
Just use the directory as the location argument.Carter Shanklin

1 Answers

6
votes

The LOCATION parameter of a hive's create table statement takes as argument a *hdfs_path* (See here). Such a path cannot be file path, but must be a directory path, hence the error you get.

In your case, you could put the required files under a specific directory und specify this very directory in the LOCATION clause of the create table statement.