I'm pretty new to Hive and HDFS, but I have managed to make a functioning HiveClient in java, that successfully connects and performs queries on my HDFS server.That is, all queries except select statements.
My code looks like this:
Statement stmt; ResultSet res; try { stmt = con.createStatement(); res = stmt.executeQuery("select * from my_table"); while (res.next()) { System.out.println(res.getString(1)); } res.close(); stmt.close(); con.close(); } catch (SQLExceptionex) { ex.printStackTrace(); }
When I run it, the error is this:
java.sql.SQLException: Query returned non-zero code: 9, cause: FAILED: Execution Error, return code -101 from shark.execution.SparkTask at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:194) at se.HiveClient.doQuery(HiveClient.java:56) at se.HiveClient.main(HiveClient.java:82)
but if I instead do a create table or show tables, it runs perfectly. Could there be a case of missing configuration or privileges? Or something else entirely?
Any ideas as to where I may have done wrong or missed something is most appreciated.
It should be a permissions issue.
Creation of tables or showing tables require hive to get metadata from its database. Actual selection of data requires to read a file. Check what are the permissions given to the file.
Hive would probably be querying as the hive user and hence either should be a owner of the file or should be in the right group.
This seems to be a similar issue: http://forums.pentaho.com/archive/index.php/t-89586.html