private CommandProcessorResponse setVariable(String varname, String varvalue){ SessionState ss = SessionState.get(); if (varname.startsWith(SetProcessor.ENV_PREFIX)){ ss.err.println("env:* variables can not be set."); return new CommandProcessorResponse(1); } else if (varname.startsWith(SetProcessor.SYSTEM_PREFIX)){ String propName = varname.substring(SetProcessor.SYSTEM_PREFIX.length()); System.getProperties().setProperty(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); return new CommandProcessorResponse(0); } else if (varname.startsWith(SetProcessor.HIVECONF_PREFIX)){ String propName = varname.substring(SetProcessor.HIVECONF_PREFIX.length()); ss.getConf().set(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); return new CommandProcessorResponse(0); } else { ss.getConf().set(varname, new VariableSubstitution().substitute(ss.getConf(),varvalue) ); return new CommandProcessorResponse(0); } }
public String substitute(HiveConf conf, String expr) { if (expr == null) { return expr; } if (HiveConf.getBoolVar(conf, ConfVars.HIVEVARIABLESUBSTITUTE)) { l4j.debug("Substitution is on: " + expr); } else { return expr; } int depth = HiveConf.getIntVar(conf, ConfVars.HIVEVARIABLESUBSTITUTEDEPTH); return substitute(conf, expr, depth); } }
public static int setVariable(String varname, String varvalue) throws Exception { SessionState ss = SessionState.get(); if (varvalue.contains("\n")){ ss.err.println("Warning: Value had a \\n character in it."); } varname = varname.trim(); if (varname.startsWith(ENV_PREFIX)){ ss.err.println("env:* variables can not be set."); return 1; } else if (varname.startsWith(SYSTEM_PREFIX)){ String propName = varname.substring(SYSTEM_PREFIX.length()); System.getProperties().setProperty(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); } else if (varname.startsWith(HIVECONF_PREFIX)){ String propName = varname.substring(HIVECONF_PREFIX.length()); setConf(varname, propName, varvalue, false); } else if (varname.startsWith(HIVEVAR_PREFIX)) { String propName = varname.substring(HIVEVAR_PREFIX.length()); ss.getHiveVariables().put(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); } else if (varname.startsWith(METACONF_PREFIX)) { String propName = varname.substring(METACONF_PREFIX.length()); Hive hive = Hive.get(ss.getConf()); hive.setMetaConf(propName, new VariableSubstitution().substitute(ss.getConf(), varvalue)); } else { setConf(varname, varname, varvalue, true); } return 0; }
public static int setVariable(String varname, String varvalue) throws Exception { SessionState ss = SessionState.get(); if (varvalue.contains("\n")){ ss.err.println("Warning: Value had a \\n character in it."); } varname = varname.trim(); if (varname.startsWith(ENV_PREFIX)){ ss.err.println("env:* variables can not be set."); return 1; } else if (varname.startsWith(SYSTEM_PREFIX)){ String propName = varname.substring(SYSTEM_PREFIX.length()); System.getProperties().setProperty(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); } else if (varname.startsWith(HIVECONF_PREFIX)){ String propName = varname.substring(HIVECONF_PREFIX.length()); setConf(varname, propName, varvalue, true); } else if (varname.startsWith(HIVEVAR_PREFIX)) { String propName = varname.substring(HIVEVAR_PREFIX.length()); ss.getHiveVariables().put(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); } else if (varname.startsWith(METACONF_PREFIX)) { String propName = varname.substring(METACONF_PREFIX.length()); Hive hive = Hive.get(ss.getConf()); hive.setMetaConf(propName, new VariableSubstitution().substitute(ss.getConf(), varvalue)); } else { setConf(varname, varname, varvalue, true); } return 0; }
public static int setVariable(String varname, String varvalue) throws Exception { SessionState ss = SessionState.get(); if (varvalue.contains("\n")){ ss.err.println("Warning: Value had a \\n character in it."); } varname = varname.trim(); if (varname.startsWith(ENV_PREFIX)){ ss.err.println("env:* variables can not be set."); return 1; } else if (varname.startsWith(SYSTEM_PREFIX)){ String propName = varname.substring(SYSTEM_PREFIX.length()); System.getProperties().setProperty(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); } else if (varname.startsWith(HIVECONF_PREFIX)){ String propName = varname.substring(HIVECONF_PREFIX.length()); setConf(varname, propName, varvalue, true); } else if (varname.startsWith(HIVEVAR_PREFIX)) { String propName = varname.substring(HIVEVAR_PREFIX.length()); ss.getHiveVariables().put(propName, new VariableSubstitution().substitute(ss.getConf(),varvalue)); } else if (varname.startsWith(METACONF_PREFIX)) { String propName = varname.substring(METACONF_PREFIX.length()); Hive hive = Hive.get(ss.getConf()); hive.setMetaConf(propName, new VariableSubstitution().substitute(ss.getConf(), varvalue)); } else { setConf(varname, varname, varvalue, true); } return 0; }
rewrittenQuery = new VariableSubstitution().substitute(conf, rewrittenQuery); return rewrittenQuery;
private static void setConf(String varname, String key, String varvalue, boolean register) throws IllegalArgumentException { HiveConf conf = SessionState.get().getConf(); String value = new VariableSubstitution().substitute(conf, varvalue); if (conf.getBoolVar(HiveConf.ConfVars.HIVECONFVALIDATION)) { HiveConf.ConfVars confVars = HiveConf.getConfVars(key); if (confVars != null) { if (!confVars.isType(value)) { StringBuilder message = new StringBuilder(); message.append("'SET ").append(varname).append('=').append(varvalue); message.append("' FAILED because ").append(key).append(" expects "); message.append(confVars.typeString()).append(" type value."); throw new IllegalArgumentException(message.toString()); } String fail = confVars.validate(value); if (fail != null) { StringBuilder message = new StringBuilder(); message.append("'SET ").append(varname).append('=').append(varvalue); message.append("' FAILED in validation : ").append(fail).append('.'); throw new IllegalArgumentException(message.toString()); } } else if (key.startsWith("hive.")) { throw new IllegalArgumentException("hive configuration " + key + " does not exists."); } } conf.verifyAndSet(key, value); if (register) { SessionState.get().getOverriddenConfigurations().put(key, value); } }
private static void setConf(String varname, String key, String varvalue, boolean register) throws IllegalArgumentException { HiveConf conf = SessionState.get().getConf(); String value = new VariableSubstitution().substitute(conf, varvalue); if (conf.getBoolVar(HiveConf.ConfVars.HIVECONFVALIDATION)) { HiveConf.ConfVars confVars = HiveConf.getConfVars(key); if (confVars != null) { if (!confVars.isType(value)) { StringBuilder message = new StringBuilder(); message.append("'SET ").append(varname).append('=').append(varvalue); message.append("' FAILED because ").append(key).append(" expects "); message.append(confVars.typeString()).append(" type value."); throw new IllegalArgumentException(message.toString()); } String fail = confVars.validate(value); if (fail != null) { StringBuilder message = new StringBuilder(); message.append("'SET ").append(varname).append('=').append(varvalue); message.append("' FAILED in validation : ").append(fail).append('.'); throw new IllegalArgumentException(message.toString()); } } else if (key.startsWith("hive.")) { throw new IllegalArgumentException("hive configuration " + key + " does not exists."); } } conf.verifyAndSet(key, value); if (register) { SessionState.get().getOverriddenConfigurations().put(key, value); } }
private static void setConf(String varname, String key, String varvalue, boolean register) throws IllegalArgumentException { HiveConf conf = SessionState.get().getConf(); String value = new VariableSubstitution().substitute(conf, varvalue); if (conf.getBoolVar(HiveConf.ConfVars.HIVECONFVALIDATION)) { HiveConf.ConfVars confVars = HiveConf.getConfVars(key); if (confVars != null) { if (!confVars.isType(value)) { StringBuilder message = new StringBuilder(); message.append("'SET ").append(varname).append('=').append(varvalue); message.append("' FAILED because ").append(key).append(" expects "); message.append(confVars.typeString()).append(" type value."); throw new IllegalArgumentException(message.toString()); } String fail = confVars.validate(value); if (fail != null) { StringBuilder message = new StringBuilder(); message.append("'SET ").append(varname).append('=').append(varvalue); message.append("' FAILED in validation : ").append(fail).append('.'); throw new IllegalArgumentException(message.toString()); } } else if (key.startsWith("hive.")) { throw new IllegalArgumentException("hive configuration " + key + " does not exists."); } } conf.verifyAndSet(key, value); if (register) { SessionState.get().getOverriddenConfigurations().put(key, value); } }
public CommandProcessorResponse run(String command) { try { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); PrintStream oldOut = System.out; if (ss != null && ss.out != null) { System.setOut(ss.out); } int ret = dfs.run(tokens); if (ret != 0) { console.printError("Command failed with exit code = " + ret); } System.setOut(oldOut); return new CommandProcessorResponse(ret); } catch (Exception e) { console.printError("Exception raised from DFSShell.run " + e.getLocalizedMessage(), org.apache.hadoop.util.StringUtils .stringifyException(e)); return new CommandProcessorResponse(1); } }
public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 2 || (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: add [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1); } for (int i = 1; i < tokens.length; i++) { ss.add_resource(t, tokens[i]); } return new CommandProcessorResponse(0); }
@Override public CommandProcessorResponse run(String command) { try { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); CommandProcessorResponse authErrResp = CommandUtil.authorizeCommand(ss, HiveOperationType.DFS, Arrays.asList(tokens)); if(authErrResp != null){ // there was an authorization issue return authErrResp; } PrintStream oldOut = System.out; if (ss != null && ss.out != null) { System.setOut(ss.out); } int ret = dfs.run(tokens); if (ret != 0) { console.printError("Command failed with exit code = " + ret); } System.setOut(oldOut); return new CommandProcessorResponse(ret, null, null, dfsSchema); } catch (Exception e) { console.printError("Exception raised from DFSShell.run " + e.getLocalizedMessage(), org.apache.hadoop.util.StringUtils .stringifyException(e)); return new CommandProcessorResponse(1); } }
void parse(SessionState ss) throws CompileProcessorException { if (ss != null){ command = new VariableSubstitution().substitute(ss.getConf(), command);
public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 1 || (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: delete [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1); } if (tokens.length >= 2) { for (int i = 1; i < tokens.length; i++) { ss.delete_resource(t, tokens[i]); } } else { ss.delete_resource(t); } return new CommandProcessorResponse(0); } }
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 1 || (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: delete [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1); } CommandProcessorResponse authErrResp = CommandUtil.authorizeCommand(ss, HiveOperationType.DELETE, Arrays.asList(tokens)); if(authErrResp != null){ // there was an authorization issue return authErrResp; } if (tokens.length >= 2) { ss.delete_resources(t, Arrays.asList(Arrays.copyOfRange(tokens, 1, tokens.length))); } else { ss.delete_resources(t); } return new CommandProcessorResponse(0); } }
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution().substitute(ss.getConf(),command); String[] tokens = command.split("\\s+"); SessionState.ResourceType t; if (tokens.length < 2 || (t = SessionState.find_resource_type(tokens[0])) == null) { console.printError("Usage: add [" + StringUtils.join(SessionState.ResourceType.values(), "|") + "] <value> [<value>]*"); return new CommandProcessorResponse(1); } CommandProcessorResponse authErrResp = CommandUtil.authorizeCommand(ss, HiveOperationType.ADD, Arrays.asList(tokens)); if(authErrResp != null){ // there was an authorization issue return authErrResp; } try { ss.add_resources(t, Arrays.asList(Arrays.copyOfRange(tokens, 1, tokens.length))); } catch (Exception e) { return CommandProcessorResponse.create(e); } return new CommandProcessorResponse(0); }
cmd_1 = new VariableSubstitution().substitute(ss.getConf(), cmd_1); shell_cmd = new VariableSubstitution().substitute(ss.getConf(), shell_cmd);
cmd_1 = new VariableSubstitution().substitute(ss.getConf(), cmd_1); shell_cmd = new VariableSubstitution().substitute(ss.getConf(), shell_cmd);
shell_cmd = new VariableSubstitution().substitute(ss.getConf(), shell_cmd);
prompt = new VariableSubstitution().substitute(conf, prompt); prompt2 = spacesForString(prompt);