通过kerberos认证后通过jdbc访问hive数据库,对数据库进行创表后准备从hdfs中插入数据,插入dir目录下的所有csv文件片段数据,报错java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask
sql = "load data inpath '/xxx/dir/*.csv' into table database.tableName"
statement.execute(sql)
java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:296)
at org.apache.hive.jdbc.HiveStatement.executeUpdate(HiveStatement.java:406)
可能的原因是没有对dir这个目录进行授权,需要对其授予权限为777,
hdfs dfs -chown -R 777 /xxx/dir
或者通过代码获取到hadoop的org.apache.hadoop.fs.FileSystem 文件管理对象fs,需要在代码中通过kerberos认证后获得,然后fs.setPermission(new Path(path), FsPermission.valueOf(“drwxrwxrwx”));