How do I creat external table based on an existing hdfs data file on hive


#1

Hello,

I already copied a hdfs data file to

hdfs dfs -cp /public/retail_db/products/part-00000 products/.

Now I want to create external table in hive based on this data file:

create external table products_hive (product_id int, product_category_id int, product_name string, product_description string, product_price decimal(8,2), product_image string)
row format delimited fields terminated by ','
location 'products/part-00000';

I got this error:
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: hdfs://nn01.itversity.com:8020./products/part-00000)

Now I modified it to:
create external table products_hive (product_id int, product_category_id int, product_name string, product_description string, product_price decimal(8,2), product_image string)
row format delimited fields terminated by ','
location ‘/products/’;

The new error is:
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:java.security.AccessControlException: Permission denied: user=paslechoix, access=WRITE, inode="/":hdfs:hdfs:drwxrwxr-x

What should I use in the create table statement?

Thank you very much.