Author: hashutosh
Date: Tue Jun 26 03:30:54 2012
New Revision: 1353808

URL: http://svn.apache.org/viewvc?rev=1353808&view=rev
Log:
HIVE-2021 : Add a configuration property that sets the variable substitution 
max depth (Edward Capriolo via Ashutosh Chauhan)

Modified:
    hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
    hive/trunk/conf/hive-default.xml.template
    
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/VariableSubstitution.java

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: 
http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1353808&r1=1353807&r2=1353808&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java 
(original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Tue 
Jun 26 03:30:54 2012
@@ -534,6 +534,7 @@ public class HiveConf extends Configurat
 
     // Hive Variables
     HIVEVARIABLESUBSTITUTE("hive.variable.substitute", true),
+    HIVEVARIABLESUBSTITUTEDEPTH("hive.variable.substitute.depth", 40),
 
     SEMANTIC_ANALYZER_HOOK("hive.semantic.analyzer.hook", ""),
 

Modified: hive/trunk/conf/hive-default.xml.template
URL: 
http://svn.apache.org/viewvc/hive/trunk/conf/hive-default.xml.template?rev=1353808&r1=1353807&r2=1353808&view=diff
==============================================================================
--- hive/trunk/conf/hive-default.xml.template (original)
+++ hive/trunk/conf/hive-default.xml.template Tue Jun 26 03:30:54 2012
@@ -1037,6 +1037,11 @@
   <description>This enables substitution using syntax like ${var} 
${system:var} and ${env:var}.</description>
 </property>
 
+<property>
+  <name>hive.variable.substitute.depth</name>
+  <value>40</value>
+  <description>The maximum replacements the substitution engine will 
do.</description>
+</property>
 
 <property>
   <name>hive.security.authorization.enabled</name>

Modified: 
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/VariableSubstitution.java
URL: 
http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/VariableSubstitution.java?rev=1353808&r1=1353807&r2=1353808&view=diff
==============================================================================
--- 
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/VariableSubstitution.java
 (original)
+++ 
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/VariableSubstitution.java
 Tue Jun 26 03:30:54 2012
@@ -31,7 +31,6 @@ public class VariableSubstitution {
 
   private static final Log l4j = LogFactory.getLog(VariableSubstitution.class);
   protected static Pattern varPat = 
Pattern.compile("\\$\\{[^\\}\\$\u0020]+\\}");
-  protected static int MAX_SUBST = 40;
 
   private String getSubstitute(HiveConf conf, String var) {
     String val = null;
@@ -74,7 +73,7 @@ public class VariableSubstitution {
     }
     Matcher match = varPat.matcher("");
     String eval = expr;
-    for(int s=0; s<MAX_SUBST; s++) {
+    for(int s=0;s<conf.getIntVar(ConfVars.HIVEVARIABLESUBSTITUTEDEPTH); s++) {
       match.reset(eval);
       if (!match.find()) {
         return eval;
@@ -91,6 +90,6 @@ public class VariableSubstitution {
       eval = eval.substring(0, match.start())+val+eval.substring(match.end());
     }
     throw new IllegalStateException("Variable substitution depth too large: "
-                                    + MAX_SUBST + " " + expr);
+                                    + 
conf.getIntVar(ConfVars.HIVEVARIABLESUBSTITUTEDEPTH) + " " + expr);
   }
 }


Reply via email to