diff --git data/files/json.txt data/files/json.txt index 6bb8a0a..9be5009 100644 --- data/files/json.txt +++ data/files/json.txt @@ -1 +1 @@ -{"store":{"fruit":[{"weight":8,"type":"apple"},{"weight":9,"type":"pear"}],"basket":[[1,2,{"b":"y","a":"x"}],[3,4],[5,6]],"book":[{"author":"Nigel Rees","title":"Sayings of the Century","category":"reference","price":8.95},{"author":"Herman Melville","title":"Moby Dick","category":"fiction","price":8.99,"isbn":"0-553-21311-3"},{"author":"J. R. R. Tolkien","title":"The Lord of the Rings","category":"fiction","reader":[{"age":25,"name":"bob"},{"age":26,"name":"jack"}],"price":22.99,"isbn":"0-395-19395-8"}],"bicycle":{"price":19.95,"color":"red"}},"email":"amy@only_for_json_udf_test.net","owner":"amy"} +{"store":{"fruit":[{"weight":8,"type":"apple"},{"weight":9,"type":"pear"}],"basket":[[1,2,{"b":"y","a":"x"}],[3,4],[5,6]],"book":[{"author":"Nigel Rees","title":"Sayings of the Century","category":"reference","price":8.95},{"author":"Herman Melville","title":"Moby Dick","category":"fiction","price":8.99,"isbn":"0-553-21311-3"},{"author":"J. R. R. Tolkien","title":"The Lord of the Rings","category":"fiction","reader":[{"age":25,"name":"bob"},{"age":26,"name":"jack"}],"price":22.99,"isbn":"0-395-19395-8"}],"bicycle":{"price":19.95,"color":"red"}},"email":"amy@only_for_json_udf_test.net","owner":"amy","phone.fax": "123-123-1234"} diff --git ql/src/java/org/apache/hadoop/hive/ql/udf/UDFJson.java ql/src/java/org/apache/hadoop/hive/ql/udf/UDFJson.java index 649a41f..e09886d 100644 --- ql/src/java/org/apache/hadoop/hive/ql/udf/UDFJson.java +++ ql/src/java/org/apache/hadoop/hive/ql/udf/UDFJson.java @@ -55,7 +55,7 @@ import org.json.JSONObject; + " [,] : Union operator\n" + " [start:end:step] : array slice operator\n") public class UDFJson extends UDF { - private final Pattern patternKey = Pattern.compile("^([a-zA-Z0-9_\\-]+).*"); + private final Pattern patternKey = Pattern.compile("^([a-zA-Z0-9_\\-.]+).*"); private final Pattern patternIndex = Pattern.compile("\\[([0-9]+|\\*)\\]"); // An LRU cache using a linked hash map @@ -119,7 +119,10 @@ public class UDFJson extends UDF { // Cache pathExpr String[] pathExpr = pathExprCache.get(pathString); if (pathExpr == null) { - pathExpr = pathString.split("\\.", -1); + pathExpr = pathString.split("(?