public static CommandProcessor get(String cmd) throws SQLException { return get(new String[]{cmd}, null); }
public static CommandProcessor get(String[] cmd, @Nonnull HiveConf conf) throws SQLException { CommandProcessor result = getForHiveCommand(cmd, conf); if (result != null) { return result; } if (isBlank(cmd[0])) { return null; } else { return DriverFactory.newDriver(conf); } } }
public static CommandProcessor getForHiveCommand(String[] cmd, HiveConf conf) throws SQLException { return getForHiveCommandInternal(cmd, conf, false); }
@Override public void destroy() { stop(); CommandProcessorFactory.clean(hiveConf); server = null; }
try { try (CommandProcessor proc = CommandProcessorFactory.get(tokens, (HiveConf) conf)) { if (proc instanceof IDriver) {
public static ExecuteStatementOperation newExecuteStatementOperation(HiveSession parentSession, String statement, Map<String, String> confOverlay, boolean runAsync, long queryTimeout) throws HiveSQLException { String cleanStatement = HiveStringUtils.removeComments(statement); String[] tokens = cleanStatement.trim().split("\\s+"); CommandProcessor processor = null; try { processor = CommandProcessorFactory.getForHiveCommand(tokens, parentSession.getHiveConf()); } catch (SQLException e) { throw new HiveSQLException(e.getMessage(), e.getSQLState(), e); } if (processor == null) { // runAsync, queryTimeout makes sense only for a SQLOperation // Pass the original statement to SQLOperation as sql parser can remove comments by itself return new SQLOperation(parentSession, statement, confOverlay, runAsync, queryTimeout); } return new HiveCommandOperation(parentSession, cleanStatement, processor, confOverlay); } }
public static CommandProcessor getForHiveCommand(String[] cmd, HiveConf conf) throws SQLException { return getForHiveCommandInternal(cmd, conf, false); }
public static CommandProcessor get(String cmd) throws SQLException { return get(new String[]{cmd}, null); }
public static CommandProcessor get(String[] cmd, HiveConf conf) throws SQLException { CommandProcessor result = getForHiveCommand(cmd, conf); if (result != null) { return result; } if (isBlank(cmd[0])) { return null; } else { if (conf == null) { return new Driver(); } Driver drv = mapDrivers.get(conf); if (drv == null) { drv = new Driver(); mapDrivers.put(conf, drv); } else { drv.resetQueryState(); } drv.init(); return drv; } }
@Test public void testAvailableCommands() throws Exception { enableTestOnlyCmd(conf); SessionState.start(conf); for (HiveCommand command : HiveCommand.values()) { String cmd[] = command.name().toLowerCase().split("_"); Assert.assertNotNull("Cmd " + cmd[0] + " not return null", CommandProcessorFactory .getForHiveCommandInternal(cmd, conf, command.isOnlyForTesting())); Assert.assertNotNull("Cmd " + cmd + " not return null", CommandProcessorFactory.getForHiveCommandInternal( cmd, conf, command.isOnlyForTesting())); } conf.set(HiveConf.ConfVars.HIVE_SECURITY_COMMAND_WHITELIST.toString(), ""); for (HiveCommand command : HiveCommand.values()) { String cmd[] = command.name().toLowerCase().split("_"); try { CommandProcessorFactory .getForHiveCommandInternal(cmd, conf, command.isOnlyForTesting()); Assert.fail("Expected SQLException for " + cmd[0] + " as available commands is empty"); } catch (SQLException e) { Assert.assertEquals("Insufficient privileges to execute " + cmd[0], e.getMessage()); Assert.assertEquals("42000", e.getSQLState()); } } }
public static CommandProcessor get(String cmd) { return get(cmd, null); }
@Test public void testInvalidCommands() throws Exception { Assert.assertNull("Null should have returned null", CommandProcessorFactory.getForHiveCommand(null, conf)); Assert.assertNull("Blank should have returned null", CommandProcessorFactory.getForHiveCommand(new String[]{" "}, conf)); Assert.assertNull("Set role should have returned null", CommandProcessorFactory.getForHiveCommand(new String[]{"set role"}, conf)); Assert.assertNull("Set role should have returned null", CommandProcessorFactory.getForHiveCommand(new String[]{"set", "role"}, conf)); Assert.assertNull("SQL should have returned null", CommandProcessorFactory.getForHiveCommand(new String[]{"SELECT * FROM TABLE"}, conf)); Assert.assertNull("Test only command should have returned null", CommandProcessorFactory.getForHiveCommand(new String[]{"CRYPTO --listZones"}, conf)); }
private CommandProcessor getTestCommand(final String commandName) throws SQLException { HiveCommand testCommand = HiveCommand.find(new String[]{commandName}, HiveCommand.ONLY_FOR_TESTING); if (testCommand == null) { return null; } return CommandProcessorFactory .getForHiveCommandInternal(new String[]{commandName}, SessionState.get().getConf(), testCommand.isOnlyForTesting()); }
proc = CommandProcessorFactory.get(tokens, c); } catch (SQLException e) { throw new RuntimeException(e);
public static ExecuteStatementOperation newExecuteStatementOperation( HiveSession parentSession, String statement, Map<String, String> confOverlay, boolean runAsync) throws HiveSQLException { String[] tokens = statement.trim().split("\\s+"); CommandProcessor processor = null; try { processor = CommandProcessorFactory.getForHiveCommand(tokens, parentSession.getHiveConf()); } catch (SQLException e) { throw new HiveSQLException(e.getMessage(), e.getSQLState(), e); } if (processor == null) { return new SQLOperation(parentSession, statement, confOverlay, runAsync); } return new HiveCommandOperation(parentSession, statement, processor, confOverlay); }
public static CommandProcessor getForHiveCommand(String[] cmd, HiveConf conf) throws SQLException { return getForHiveCommandInternal(cmd, conf, false); }