org.apache.hadoop.hive.ql.processors.CommandProcessorResponse Java Examples
The following examples show how to use
org.apache.hadoop.hive.ql.processors.CommandProcessorResponse.
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: AbstractMetastoreTestWithStaticConfiguration.java From incubator-sentry with Apache License 2.0 | 6 votes |
public void execHiveSQLwithOverlay(final String sqlStmt, final String userName, Map<String, String> overLay) throws Exception { final HiveConf hiveConf = new HiveConf(); for (Map.Entry<String, String> entry : overLay.entrySet()) { hiveConf.set(entry.getKey(), entry.getValue()); } UserGroupInformation clientUgi = UserGroupInformation .createRemoteUser(userName); clientUgi.doAs(new PrivilegedExceptionAction<Object>() { @Override public Void run() throws Exception { Driver driver = new Driver(hiveConf, userName); SessionState.start(new CliSessionState(hiveConf)); CommandProcessorResponse cpr = driver.run(sqlStmt); if (cpr.getResponseCode() != 0) { throw new IOException("Failed to execute \"" + sqlStmt + "\". Driver returned " + cpr.getResponseCode() + " Error: " + cpr.getErrorMessage()); } driver.close(); SessionState.get().close(); return null; } }); }
Example #5
Source File: ImpalaLineageITBase.java From atlas with Apache License 2.0 | 5 votes |
protected void runCommandWithDelay(Driver driver, String cmd, int sleepMs) throws Exception { LOG.debug("Running command '{}'", cmd); CommandProcessorResponse response = driver.run(cmd); assertEquals(response.getResponseCode(), 0); if (sleepMs != 0) { Thread.sleep(sleepMs); } }
Example #6
Source File: HiveITBase.java From atlas with Apache License 2.0 | 5 votes |
protected void runCommandWithDelay(Driver driver, String cmd, int sleepMs) throws Exception { LOG.debug("Running command '{}'", cmd); CommandProcessorResponse response = driver.run(cmd); assertEquals(response.getResponseCode(), 0); if (sleepMs != 0) { Thread.sleep(sleepMs); } }
Example #7
Source File: HiveITBase.java From incubator-atlas with Apache License 2.0 | 5 votes |
protected void runCommandWithDelay(Driver driver, String cmd, int sleepMs) throws Exception { LOG.debug("Running command '{}'", cmd); ss.setCommandType(null); CommandProcessorResponse response = driver.run(cmd); assertEquals(response.getResponseCode(), 0); if (sleepMs != 0) { Thread.sleep(sleepMs); } }
Example #8
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); } }
Example #9
Source File: HoodieHiveClient.java From hudi with Apache License 2.0 | 2 votes |
/** * Execute a update in hive using Hive Driver. * * @param sql SQL statement to execute */ public CommandProcessorResponse updateHiveSQLUsingHiveDriver(String sql) { List<CommandProcessorResponse> responses = updateHiveSQLs(Collections.singletonList(sql)); return responses.get(responses.size() - 1); }