Support Questions

Find answers, ask questions, and share your expertise

Load data local inpath says "invalid path" when my file is right where I tell it to look!

avatar
New Contributor

I'm writing a program in Java, where I need to load a file from my local disk into Hive. I'm using the JDBC driver for this. The query my program generates looks like this:

 

load data local inpath '/home/cloudera/temp/testpart/90d0584c080a6607128e03c0cee8a2a666bf83f1b11882d24b72ae420e60e8a3.lzo' into table checkpoint_part partition(year=2014, month=04, day=03, hour=12, minute=17)

 

Yes, the program is running in the same machine where both the file and Hive are. I'm getting this exception:


java.sql.SQLException: Error while processing statement: FAILED: SemanticException Line 1:23 Invalid path '"/home/cloudera/temp/testpart/90d0584c080a6607128e03c0cee8a2a666bf83f1b11882d24b72ae420e60e8a3.lzo"': No files matching path file:/home/cloudera/temp/testpart/90d0584c080a6607128e03c0cee8a2a666bf83f1b11882d24b72ae420e60e8a3.lzo
    at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:159)
    at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:147)
    at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:182)
    at Program.main(Program.java:230)

Anyone could help me with this? I'm completely lost. I mean, the file is right there.

5 REPLIES 5

avatar
Mentor
When using the JDBC driver, the command executes on the HiveServer2 side. The file is evaluated to locally exist on the server, which is not true in your case (it exists on the local client program machine).

Try instead to load the file to HDFS first, and use a HDFS URI in the LOAD DATA statement to make the server find it.

Does this make sense?

avatar
Explorer

Hello Harsh,

Even if I am using the Hive CLI, which i presume uses ODBC driver, still I get the same error if my path is /root/filename.csv.

 

hive> load data local inpath "/root/veraxinternal.csv" overwrite into table veraxexternal;
FAILED: SemanticException Line 1:23 Invalid path '"/root/veraxinternal.csv"': No files matching path file:/root/veraxinternal.csv

 

If I copy the same file to a different a location and do loadoperation it goes well. What's the logic here? does not hive accept files from /Root? By the way how can I trace this if I need to debug

 

 

hive> load data local inpath "/home/cloudera/veraxinternal.csv" overwrite into table veraxexternal;
Copying data from file:/home/cloudera/veraxinternal.csv
Copying file: file:/home/cloudera/veraxinternal.csv
Loading data to table default.veraxexternal
chgrp: changing ownership of 'hdfs://quickstart.cloudera:8020/user/hive/warehouse/veraxexternal': User does not belong to hive
Table default.veraxexternal stats: [numFiles=1, numRows=0, totalSize=113, rawDataSize=0]
OK

 

 

avatar
Rising Star

It sounds like a permission issue.  Can you check if the user of hive has permission for that file?

avatar
Mentor
Indeed, as szehon mentions, the use of /root may be your problem, especially if you've invoked the Hive CLI via a sudo command. The /root is protected against access from anyone but the root user.

avatar
New Contributor

This is my testing result at the Hadoop master node which used for namenode and hive server2.

 

When I executing beeline for local file loading to a table, I met same error.

It was the permission issue on the file to the hive user which is the owner of HiveServer2 process.

 

It was solve when I grant read permission the file including whole path.

 

Please check the file accessible permission as this.

sudo -u hive cat ~/test.txt