You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by na...@apache.org on 2009/10/21 08:31:50 UTC

svn commit: r827898 - in /hadoop/hive/trunk: CHANGES.txt metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java ql/src/test/queries/clientpositive/input_part10.q ql/src/test/results/clientpositive/input_part10.q.out

Author: namit
Date: Wed Oct 21 06:31:50 2009
New Revision: 827898

URL: http://svn.apache.org/viewvc?rev=827898&view=rev
Log:
undo
HIVE-883. URISyntaxException when partition value contains special chars
(Zheng Shao via namit)

The tests were failing - committed by mistake, looked at the wrong results
file


Removed:
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/input_part10.q
    hadoop/hive/trunk/ql/src/test/results/clientpositive/input_part10.q.out
Modified:
    hadoop/hive/trunk/CHANGES.txt
    hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java

Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=827898&r1=827897&r2=827898&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Wed Oct 21 06:31:50 2009
@@ -206,9 +206,6 @@
     HIVE-885. Better error messages for debugging serde problem at reducer
     input (Zheng Shao via namit)
 
-    HIVE-883. URISyntaxException when partition value contains special chars
-    (Zheng Shao via namit)
-
 Release 0.4.0 -  Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java?rev=827898&r1=827897&r2=827898&view=diff
==============================================================================
--- hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java (original)
+++ hadoop/hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java Wed Oct 21 06:31:50 2009
@@ -21,7 +21,6 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.BitSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -162,77 +161,13 @@
     return false;
   }
 
-  // NOTE: This is for generating the internal path name for partitions. Users
-  // should always use the MetaStore API to get the path name for a partition.
-  // Users should not directly take partition values and turn it into a path 
-  // name by themselves, because the logic below may change in the future.
-  //
-  // In the future, it's OK to add new chars to the escape list, and old data
-  // won't be corrupt, because the full path name in metastore is stored.
-  // In that case, Hive will continue to read the old data, but when it creates
-  // new partitions, it will use new names.
-  static BitSet charToEscape = new BitSet(128);
-  static {
-    for (char c = 0; c < ' ' ; c++) {
-      charToEscape.set(c);
-    }
-    char[] clist = new char[] { '"', '#', '%', '\'', '*', '/', ':',
-        '=', '?', '\\', '\u00FF'
-    };
-    for (char c : clist) {
-      charToEscape.set(c);
-    }
-  }
-  static boolean needsEscaping(char c) {
-    return c >= 0 && c < charToEscape.size()
-        && charToEscape.get(c); 
-  }
-  
-  static String escapePathName(String path) {
-    StringBuilder sb = new StringBuilder();
-    for (int i = 0; i < path.length(); i++) {
-      char c = path.charAt(i);
-      if (needsEscaping(c)) {
-        sb.append('%');
-        sb.append(String.format("%1$02X", (int)c));
-      } else {
-        sb.append(c);
-      }
-    }
-    return sb.toString();
-  }
-  static String unescapePathName(String path) {
-    StringBuilder sb = new StringBuilder();
-    for (int i = 0; i < path.length(); i++) {
-      char c = path.charAt(i);
-      if (c == '%' && i + 2 < path.length()) {
-        int code = -1;
-        try {
-          code = Integer.valueOf(path.substring(i+1, i+3), 16);
-        } catch (Exception e) {
-          code = -1;
-        }
-        if (code >= 0) {
-          sb.append((char)code);
-          i += 2;
-          continue;
-        }
-      }
-      sb.append(c);
-    }    
-    return sb.toString();
-  }
-  
   public static String makePartName(Map<String, String> spec) throws MetaException {
     StringBuffer suffixBuf = new StringBuffer();
     for(Entry<String, String> e: spec.entrySet()) {
       if(e.getValue() == null  || e.getValue().length() == 0) {
         throw new MetaException("Partition spec is incorrect. " + spec);
       }
-      suffixBuf.append(escapePathName(e.getKey()));
-      suffixBuf.append('=');
-      suffixBuf.append(escapePathName(e.getValue()));
-      suffixBuf.append(Path.SEPARATOR);
+      suffixBuf.append(e.getKey() + "=" + e.getValue() + "/");
     }
     return suffixBuf.toString();
   }
@@ -249,8 +184,8 @@
       String component = currPath.getName();
       Matcher m = pat.matcher(component);
       if (m.matches()) {
-        String k = unescapePathName(m.group(1));
-        String v = unescapePathName(m.group(2));
+        String k = m.group(1);
+        String v = m.group(2);
 
         if (partSpec.containsKey(k)) {
           throw new MetaException("Partition name is invalid. Key " + k + " defined at two levels");
@@ -306,10 +241,9 @@
       if(i > 0) {
         name.append(Path.SEPARATOR);
       }
-      name.append(escapePathName((partCols.get(i)).getName().toLowerCase()));
+      name.append((partCols.get(i)).getName().toLowerCase());
       name.append('=');
-      name.append(escapePathName(vals.get(i)));
-      name.append('/');
+      name.append(vals.get(i));
     }
     return name.toString();
   }