Help Center/ MapReduce Service/ Troubleshooting/ Using Hive/ An Error Is Reported When the "load data local inpath" Command Is Executed
Updated on 2022-07-25 GMT+08:00

An Error Is Reported When the "load data local inpath" Command Is Executed

Symptom

The following errors are reported when the load data local inpath command is executed:

  • Error 1:
    HiveAccessControlException Permission denied. Principal [name=user1, type=USER] does not have following privileges on Object [type=LOCAL_URI, name=file:/tmp/input/mapdata] for operation LOAD : [SELECT, INSERT, DELETE]
  • Error 2:
    HiveAccessControlException Permission denied. Principal [name=user1, type=USER] does not have following privileges on Object [type=LOCAL_URI, name=file:/tmp/input/mapdata] for operation LOAD : [OBJECT OWNERSHIP]
  • Error 3:
    SemanticException Line 1:23 Invalid path ''/tmp/input/mapdata'': No files matching path file:/tmp/input/mapdata  

Cause Analysis

The current user does not have the permission to operate the directory or the directory does not exist on the node where HiveServer is located.

Solution

Generally, you are not advised to use local files to load data to Hive tables. You are advised to store local files in HDFS and then load data from the cluster.

Hive has the following requirements on the load data local inpath command:
  • The file must be stored on the HiveServer node, because all commands are sent to the active HiveServer for execution.
  • User omm must have the read permission for the file and read and execution permissions for the directory where the file is located, because the HiveServer process is started by user omm in the OS.
  • The file owner must be the user who executes the command.
  • The current user must have read and write permissions for the file.
  • The file format must be the same as the storage format specified by the table. For example, if stored as rcfile is specified during table creation but the file format is TXT, it is unsatisfied.
  • The file name cannot start with an underscore (_) or period (.). A file whose name starts with an underscore (_) or period (.) will be ignored.