public String substituteVariables(HiveConf conf, String line) { if (!beeLine.isBeeLine()) { // Substitution is only supported in non-beeline mode. return new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return getHiveVariables(); } }).substitute(conf, line); } return line; }
public String substitute(HiveConf conf, String expr) { if (expr == null) { return expr; } if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVEVARIABLESUBSTITUTE)) { l4j.debug("Substitution is on: " + expr); } else { return expr; } int depth = HiveConf.getIntVar(conf, HiveConf.ConfVars.HIVEVARIABLESUBSTITUTEDEPTH); return substitute(conf, expr, depth); } }
public VariableSubstitution getVariableSubstitution() { // Make sure to set the session state for this thread before returning the VariableSubstitution. If not set, // hivevar:s will not be evaluated. SessionState.setCurrentSessionState(currentSessionState); final SessionState ss = currentSessionState; return new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return ss.getHiveVariables(); } }); } }
public String substitute(HiveConf conf, String expr) { if (expr == null) { return expr; } if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVEVARIABLESUBSTITUTE)) { l4j.debug("Substitution is on: " + expr); } else { return expr; } int depth = HiveConf.getIntVar(conf, HiveConf.ConfVars.HIVEVARIABLESUBSTITUTEDEPTH); return substitute(conf, expr, depth); } }
public VariableSubstitution getVariableSubstitution() { // Make sure to set the session state for this thread before returning the VariableSubstitution. If not set, // hivevar:s will not be evaluated. SessionState.setCurrentSessionState(currentSessionState); final SessionState ss = currentSessionState; return new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return ss.getHiveVariables(); } }); } }
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution(() -> SessionState.get().getHiveVariables()).substitute(ss.getConf(), command); String[] tokens = command.split("\\s+"); if (tokens.length < 1) { return returnErrorResponse("Command arguments are empty."); } String params[] = Arrays.copyOfRange(tokens, 1, tokens.length); try { return llapCacheCommandHandler(ss, params); } catch (Exception e) { return returnErrorResponse(e.getMessage()); } }
public String expandVariableSubstitutes(String expression) { return getVariableSubstitution().substitute(getHiveConf(), expression); }
@Override public CommandProcessorResponse run(String command) { SessionState ss = SessionState.get(); command = new VariableSubstitution(() -> SessionState.get().getHiveVariables()).substitute(ss.getConf(), command); String[] tokens = command.split("\\s+"); if (tokens.length < 1) { return returnErrorResponse("Command arguments are empty."); } String params[] = Arrays.copyOfRange(tokens, 1, tokens.length); try { return llapClusterCommandHandler(ss, params); } catch (Exception e) { return returnErrorResponse(e.getMessage()); } }
public String expandVariableSubstitutes(String expression) { return getVariableSubstitution().substitute(getHiveConf(), expression); }
String result = null; HiveConf conf = ss.getConf(); String value = new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return ss.getHiveVariables(); }).substitute(conf, varvalue); if (conf.getBoolVar(HiveConf.ConfVars.HIVECONFVALIDATION)) { HiveConf.ConfVars confVars = HiveConf.getConfVars(key);
@Override public String expandVariableSubstitutes(String expression) { assertStarted(); HiveConf hiveConf = getHiveConf(); Preconditions.checkNotNull(hiveConf); return hiveServerContainer.getVariableSubstitution().substitute(hiveConf, expression); }
rewrittenQuery = new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(conf, rewrittenQuery); return rewrittenQuery;
@Override public String expandVariableSubstitutes(String expression) { assertStarted(); HiveConf hiveConf = getHiveConf(); Preconditions.checkNotNull(hiveConf); return hiveServerContainer.getVariableSubstitution().substitute(hiveConf, expression); }
String propName = varname.substring(SYSTEM_PREFIX.length()); System.getProperties() .setProperty(propName, new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(ss.getConf(), varvalue)); } else if (varname.startsWith(HIVECONF_PREFIX)){ String propName = varname.substring(HIVECONF_PREFIX.length()); } else if (varname.startsWith(HIVEVAR_PREFIX)) { String propName = varname.substring(HIVEVAR_PREFIX.length()); ss.getHiveVariables().put(propName, new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).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(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(ss.getConf(), varvalue)); } else {
rewrittenQuery = new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(conf, rewrittenQuery); return rewrittenQuery;
void parse(SessionState ss) throws CompileProcessorException { if (ss != null){ command = new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(ss.getConf(), command);
String result = null; HiveConf conf = SessionState.get().getConf(); String value = new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(conf, varvalue); if (conf.getBoolVar(HiveConf.ConfVars.HIVECONFVALIDATION)) { HiveConf.ConfVars confVars = HiveConf.getConfVars(key);
String propName = varname.substring(SYSTEM_PREFIX.length()); System.getProperties() .setProperty(propName, new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(ss.getConf(), varvalue)); } else if (varname.startsWith(HIVECONF_PREFIX)){ String propName = varname.substring(HIVECONF_PREFIX.length()); } else if (varname.startsWith(HIVEVAR_PREFIX)) { String propName = varname.substring(HIVEVAR_PREFIX.length()); ss.getHiveVariables().put(propName, new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).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(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(ss.getConf(), varvalue)); } else {
void parse(SessionState ss) throws CompileProcessorException { if (ss != null){ command = new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return SessionState.get().getHiveVariables(); }).substitute(ss.getConf(), command);
@Test public void testVariableSource() throws InterruptedException { final VariableSubstitution variableSubstitution = new VariableSubstitution(new HiveVariableSource() { @Override public Map<String, String> getHiveVariable() { return TestVariableSubstitution.getMySource().map; } }); String v = variableSubstitution.substitute(new HiveConf(), "${a}"); Assert.assertEquals("${a}", v); TestVariableSubstitution.getMySource().put("a", "b"); v = variableSubstitution.substitute(new HiveConf(), "${a}"); Assert.assertEquals("b", v); } }