Java Code Examples for org.apache.hadoop.hive.ql.processors.CommandProcessorResponse#getErrorMessage()

The following examples show how to use org.apache.hadoop.hive.ql.processors.CommandProcessorResponse#getErrorMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SentryConfigTool.java    From incubator-sentry with Apache License 2.0 7 votes vote down vote up
public void verifyLocalQuery(String queryStr) throws Exception {
  // setup Hive driver
  SessionState session = new SessionState(getHiveConf());
  SessionState.start(session);
  Driver driver = new Driver(session.getConf(), getUser());

  // compile the query
  CommandProcessorResponse compilerStatus = driver
      .compileAndRespond(queryStr);
  if (compilerStatus.getResponseCode() != 0) {
    String errMsg = compilerStatus.getErrorMessage();
    if (errMsg.contains(HiveAuthzConf.HIVE_SENTRY_PRIVILEGE_ERROR_MESSAGE)) {
      printMissingPerms(getHiveConf().get(
          HiveAuthzConf.HIVE_SENTRY_AUTH_ERRORS));
    }
    throw new SemanticException("Compilation error: "
        + compilerStatus.getErrorMessage());
  }
  driver.close();
  System.out
      .println("User " + getUser() + " has privileges to run the query");
}
 
Example 2
Source File: HiveClient.java    From Kylin with Apache License 2.0 5 votes vote down vote up
/**
 * 
 * @param hql
 * @throws CommandNeedRetryException
 * @throws IOException
 */
public void executeHQL(String hql) throws CommandNeedRetryException, IOException {
    CommandProcessorResponse response = getDriver().run(hql);
    int retCode = response.getResponseCode();
    if (retCode != 0) {
        String err = response.getErrorMessage();
        throw new IOException("Failed to execute hql [" + hql + "], error message is: " + err);
    }
}