HIVE-12346:Internally used variables in HiveConf should not be settable via command (Chaoyu Tang, reviewed by Xuefu Zhang)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/eef89a21 Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/eef89a21 Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/eef89a21 Branch: refs/heads/master-fixed Commit: eef89a2105a6ec401d18f9f1de2912a89c8eb4ac Parents: 3bf280f Author: ctang <ctang...@gmail.com> Authored: Fri Nov 6 08:51:41 2015 -0500 Committer: ctang <ctang...@gmail.com> Committed: Fri Nov 6 08:51:53 2015 -0500 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hive/conf/HiveConf.java | 15 ++++++++++++++- .../clientnegative/set_hiveconf_internal_variable0.q | 4 ++++ .../clientnegative/set_hiveconf_internal_variable1.q | 4 ++++ .../set_hiveconf_internal_variable0.q.out | 11 +++++++++++ .../set_hiveconf_internal_variable1.q.out | 11 +++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/eef89a21/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java ---------------------------------------------------------------------- diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 98f9206..12276bf 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -2104,6 +2104,10 @@ public class HiveConf extends Configuration { METASTOREPWD.varname + "," + HIVE_SERVER2_SSL_KEYSTORE_PASSWORD.varname, "Comma separated list of configuration options which should not be read by normal user like passwords"), + HIVE_CONF_INTERNAL_VARIABLE_LIST("hive.conf.internal.variable.list", + "hive.added.files.path,hive.added.jars.path,hive.added.archives.path", + "Comma separated list of variables which are used internally and should not be configurable."), + // If this is set all move tasks at the end of a multi-insert query will only begin once all // outputs are ready HIVE_MULTI_INSERT_MOVE_TASKS_SHARE_DEPENDENCIES( @@ -2634,7 +2638,7 @@ public class HiveConf extends Configuration { } if (restrictList.contains(name)) { throw new IllegalArgumentException("Cannot modify " + name + " at runtime. It is in the list" - + "of parameters that can't be modified at runtime"); + + " of parameters that can't be modified at runtime"); } String oldValue = name != null ? get(name) : null; if (name == null || value == null || !value.equals(oldValue)) { @@ -3329,9 +3333,18 @@ public class HiveConf extends Configuration { restrictList.add(entry.trim()); } } + + String internalVariableListStr = this.getVar(ConfVars.HIVE_CONF_INTERNAL_VARIABLE_LIST); + if (internalVariableListStr != null) { + for (String entry : internalVariableListStr.split(",")) { + restrictList.add(entry.trim()); + } + } + restrictList.add(ConfVars.HIVE_IN_TEST.varname); restrictList.add(ConfVars.HIVE_CONF_RESTRICTED_LIST.varname); restrictList.add(ConfVars.HIVE_CONF_HIDDEN_LIST.varname); + restrictList.add(ConfVars.HIVE_CONF_INTERNAL_VARIABLE_LIST.varname); } private void setupHiddenSet() { http://git-wip-us.apache.org/repos/asf/hive/blob/eef89a21/ql/src/test/queries/clientnegative/set_hiveconf_internal_variable0.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientnegative/set_hiveconf_internal_variable0.q b/ql/src/test/queries/clientnegative/set_hiveconf_internal_variable0.q new file mode 100644 index 0000000..b6393e4 --- /dev/null +++ b/ql/src/test/queries/clientnegative/set_hiveconf_internal_variable0.q @@ -0,0 +1,4 @@ +-- should fail: for some internal variables which should not be settable via set command +desc src; + +set hive.added.jars.path=file://rootdir/test/added/a.jar; http://git-wip-us.apache.org/repos/asf/hive/blob/eef89a21/ql/src/test/queries/clientnegative/set_hiveconf_internal_variable1.q ---------------------------------------------------------------------- diff --git a/ql/src/test/queries/clientnegative/set_hiveconf_internal_variable1.q b/ql/src/test/queries/clientnegative/set_hiveconf_internal_variable1.q new file mode 100644 index 0000000..0038f36 --- /dev/null +++ b/ql/src/test/queries/clientnegative/set_hiveconf_internal_variable1.q @@ -0,0 +1,4 @@ +-- should fail: hive.conf.internal.variable.list is in restricted list +desc src; + +set hive.conf.internal.variable.list=; http://git-wip-us.apache.org/repos/asf/hive/blob/eef89a21/ql/src/test/results/clientnegative/set_hiveconf_internal_variable0.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientnegative/set_hiveconf_internal_variable0.q.out b/ql/src/test/results/clientnegative/set_hiveconf_internal_variable0.q.out new file mode 100644 index 0000000..61dafb4 --- /dev/null +++ b/ql/src/test/results/clientnegative/set_hiveconf_internal_variable0.q.out @@ -0,0 +1,11 @@ +PREHOOK: query: -- should fail: for some internal variables which should not be settable via set command +desc src +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@src +POSTHOOK: query: -- should fail: for some internal variables which should not be settable via set command +desc src +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@src +key string default +value string default +Query returned non-zero code: 1, cause: Cannot modify hive.added.jars.path at runtime. It is in the list of parameters that can't be modified at runtime http://git-wip-us.apache.org/repos/asf/hive/blob/eef89a21/ql/src/test/results/clientnegative/set_hiveconf_internal_variable1.q.out ---------------------------------------------------------------------- diff --git a/ql/src/test/results/clientnegative/set_hiveconf_internal_variable1.q.out b/ql/src/test/results/clientnegative/set_hiveconf_internal_variable1.q.out new file mode 100644 index 0000000..ae2dafb --- /dev/null +++ b/ql/src/test/results/clientnegative/set_hiveconf_internal_variable1.q.out @@ -0,0 +1,11 @@ +PREHOOK: query: -- should fail: hive.conf.internal.variable.list is in restricted list +desc src +PREHOOK: type: DESCTABLE +PREHOOK: Input: default@src +POSTHOOK: query: -- should fail: hive.conf.internal.variable.list is in restricted list +desc src +POSTHOOK: type: DESCTABLE +POSTHOOK: Input: default@src +key string default +value string default +Query returned non-zero code: 1, cause: Cannot modify hive.conf.internal.variable.list at runtime. It is in the list of parameters that can't be modified at runtime