Java Code Examples for org.apache.hadoop.hive.ql.Driver#run()
The following examples show how to use
org.apache.hadoop.hive.ql.Driver#run() .
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: 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 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. * @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 3
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 4
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 5
Source File: HiveTestDataGenerator.java From dremio-oss with Apache License 2.0 | 5 votes |
private void logVersion(Driver hiveDriver) throws Exception { hiveDriver.run("SELECT VERSION()"); hiveDriver.resetFetch(); hiveDriver.setMaxRows(1); List<String> result = new ArrayList<>(); hiveDriver.getResults(result); for (String values : result) { System.out.println("Test Hive instance version: " + values); } }
Example 6
Source File: HiveTestDataGenerator.java From dremio-oss with Apache License 2.0 | 5 votes |
private void logVersion(Driver hiveDriver) throws Exception { hiveDriver.run("SELECT VERSION()"); hiveDriver.resetFetch(); hiveDriver.setMaxRows(1); List<String> result = new ArrayList<>(); hiveDriver.getResults(result); for (String values : result) { System.out.println("Test Hive instance version: " + values); } }
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); } }