Java Code Examples for org.apache.hadoop.hive.ql.processors.CommandProcessorResponse#getResponseCode()
The following examples show how to use
org.apache.hadoop.hive.ql.processors.CommandProcessorResponse#getResponseCode() .
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 |
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: HiveTestUtilities.java From dremio-oss with Apache License 2.0 | 6 votes |
/** * Execute the give <i>query</i> on given <i>hiveDriver</i> instance. If a {@link CommandNeedRetryException} * exception is thrown, it tries upto 3 times before returning failure. * @param hiveDriver * @param query */ public static void executeQuery(Driver hiveDriver, String query) { CommandProcessorResponse response = null; boolean failed = false; int retryCount = 3; Exception cause = null; try { response = hiveDriver.run(query); } catch(CommandNeedRetryException retryEx) { if (--retryCount == 0) { failed = true; cause = retryEx; } } catch (Exception ex) { failed = true; cause = ex; } if (failed || response.getResponseCode() != 0 ) { throw new RuntimeException(String.format("Failed to execute command '%s', errorMsg = '%s'", query, (response != null ? response.getErrorMessage() : "")), cause); } }
Example 3
Source File: HiveTestUtilities.java From dremio-oss with Apache License 2.0 | 6 votes |
/** * Execute the give <i>query</i> on given <i>hiveDriver</i> instance. * @param hiveDriver * @param query */ public static void executeQuery(Driver hiveDriver, String query) { CommandProcessorResponse response = null; boolean failed = false; Exception cause; try { response = hiveDriver.run(query); cause = null; } catch(Exception ex) { failed = true; cause = ex; } if (failed || response.getResponseCode() != 0 ) { throw new RuntimeException(String.format("Failed to execute command '%s', errorMsg = '%s'", query, (response != null ? response.getErrorMessage() : "")), cause); } }
Example 4
Source File: HiveClient.java From Kylin with Apache License 2.0 | 5 votes |
/** * * @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); } }