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 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 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 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)); }
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 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 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 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 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); } }
query = query.replaceAll("\n", " "); if (query.trim().length() > 0) { cp = CommandProcessorFactory.getForHiveCommand(query.trim() .split("\\s+"), miniCluster.getConfig());
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); } drv.init(); return drv; } }