0

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.

Elin
  • 69
  • 1
  • 7

1 Answers1

0

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

Dhruv Kapur
  • 726
  • 1
  • 8
  • 24
  • Thanks, I upped to full permissions for all user groups for the external table files, but it still fails. When I check the user grants for my user I get nothing, should this be the case? I just assumed the Hive user is the same as my user for the server, but perhaps that's not right? Do I need to set any permissions for Hive, in config files or such? – Elin Dec 11 '14 at 16:27