hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nzh...@apache.org
Subject svn commit: r923070 [1/2] - in /hadoop/hive/trunk: ./ ql/src/java/org/apache/hadoop/hive/ql/exec/ ql/src/java/org/apache/hadoop/hive/ql/udf/xml/ ql/src/test/queries/clientpositive/ ql/src/test/results/clientpositive/
Date Mon, 15 Mar 2010 06:09:31 GMT
Author: nzhang
Date: Mon Mar 15 06:09:30 2010
New Revision: 923070

URL: http://svn.apache.org/viewvc?rev=923070&view=rev
Log:
HIVE-1027. Create UDFs for XPath expression evaluation. (Patrick Angeles via Ning Zhang)

Added:
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/GenericUDFXPath.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathBoolean.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathDouble.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathFloat.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathInteger.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathLong.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathShort.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathString.java
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathUtil.java
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath.q
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_boolean.q
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_double.q
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_float.q
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_int.q
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_long.q
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_short.q
    hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_string.q
    hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath.q.out
    hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_boolean.q.out
    hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_double.q.out
    hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_float.q.out
    hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_int.q.out
    hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_long.q.out
    hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_short.q.out
    hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_string.q.out
Modified:
    hadoop/hive/trunk/CHANGES.txt
    hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
    hadoop/hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out

Modified: hadoop/hive/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/CHANGES.txt?rev=923070&r1=923069&r2=923070&view=diff
==============================================================================
--- hadoop/hive/trunk/CHANGES.txt (original)
+++ hadoop/hive/trunk/CHANGES.txt Mon Mar 15 06:09:30 2010
@@ -51,6 +51,9 @@ Trunk -  Unreleased
     HIVE-705. Read HBase tables via Hive
     (John Sichi via namit)
 
+    HIVE-1027. Create UDFs for XPath expression evaluation
+    (Patrick Angeles via Ning Zhang)
+
   IMPROVEMENTS
     HIVE-983. Function from_unixtime takes long.
     (Ning Zhang via zshao)

Modified: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java?rev=923070&r1=923069&r2=923070&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java (original)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java Mon Mar 15 06:09:30 2010
@@ -157,6 +157,14 @@ import org.apache.hadoop.hive.ql.udf.gen
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDFWhen;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF;
 import org.apache.hadoop.hive.ql.udf.generic.GenericUDTFExplode;
+import org.apache.hadoop.hive.ql.udf.xml.GenericUDFXPath;
+import org.apache.hadoop.hive.ql.udf.xml.UDFXPathBoolean;
+import org.apache.hadoop.hive.ql.udf.xml.UDFXPathDouble;
+import org.apache.hadoop.hive.ql.udf.xml.UDFXPathFloat;
+import org.apache.hadoop.hive.ql.udf.xml.UDFXPathInteger;
+import org.apache.hadoop.hive.ql.udf.xml.UDFXPathLong;
+import org.apache.hadoop.hive.ql.udf.xml.UDFXPathShort;
+import org.apache.hadoop.hive.ql.udf.xml.UDFXPathString;
 import org.apache.hadoop.hive.serde.Constants;
 import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
 import org.apache.hadoop.hive.serde2.typeinfo.ListTypeInfo;
@@ -256,6 +264,16 @@ public final class FunctionRegistry {
 
     registerUDF("get_json_object", UDFJson.class, false);
 
+    registerUDF("xpath_string", UDFXPathString.class, false);
+    registerUDF("xpath_boolean", UDFXPathBoolean.class, false);
+    registerUDF("xpath_number", UDFXPathDouble.class, false);
+    registerUDF("xpath_double", UDFXPathDouble.class, false);
+    registerUDF("xpath_float", UDFXPathFloat.class, false);
+    registerUDF("xpath_long", UDFXPathLong.class, false);
+    registerUDF("xpath_int", UDFXPathInteger.class, false);
+    registerUDF("xpath_short", UDFXPathShort.class, false);
+    registerGenericUDF("xpath", GenericUDFXPath.class);
+
     registerUDF("+", UDFOPPlus.class, true);
     registerUDF("-", UDFOPMinus.class, true);
     registerUDF("*", UDFOPMultiply.class, true);
@@ -309,7 +327,7 @@ public final class FunctionRegistry {
     // Aggregate functions
     registerGenericUDAF("max", new GenericUDAFMax());
     registerGenericUDAF("min", new GenericUDAFMin());
-    
+
     registerGenericUDAF("sum", new GenericUDAFSum());
     registerGenericUDAF("count", new GenericUDAFCount());
     registerGenericUDAF("avg", new GenericUDAFAverage());
@@ -323,7 +341,7 @@ public final class FunctionRegistry {
     registerGenericUDAF("var_samp", new GenericUDAFVarianceSample());
 
     registerUDAF("percentile", UDAFPercentile.class);
-    
+
     // Generic UDFs
     registerGenericUDF("array", GenericUDFArray.class);
     registerGenericUDF("map", GenericUDFMap.class);
@@ -427,7 +445,7 @@ public final class FunctionRegistry {
   /**
    * Returns a set of registered function names. This is used for the CLI
    * command "SHOW FUNCTIONS;"
-   * 
+   *
    * @return set of strings contains function names
    */
   public static Set<String> getFunctionNames() {
@@ -438,7 +456,7 @@ public final class FunctionRegistry {
    * Returns a set of registered function names. This is used for the CLI
    * command "SHOW FUNCTIONS 'regular expression';" Returns an empty set when
    * the regular expression is not valid.
-   * 
+   *
    * @param funcPatternStr
    *          regular expression of the interested function names
    * @return set of strings contains function names
@@ -461,7 +479,7 @@ public final class FunctionRegistry {
 
   /**
    * Returns the set of synonyms of the supplied function.
-   * 
+   *
    * @param funcName
    *          the name of the function
    * @return Set of synonyms for funcName
@@ -509,10 +527,10 @@ public final class FunctionRegistry {
   /**
    * Find a common class that objects of both TypeInfo a and TypeInfo b can
    * convert to. This is used for comparing objects of type a and type b.
-   * 
+   *
    * When we are comparing string and double, we will always convert both of
    * them to double and then compare.
-   * 
+   *
    * @return null if no common class could be found.
    */
   public static TypeInfo getCommonClassForComparison(TypeInfo a, TypeInfo b) {
@@ -533,9 +551,9 @@ public final class FunctionRegistry {
   /**
    * Find a common class that objects of both TypeInfo a and TypeInfo b can
    * convert to. This is used for places other than comparison.
-   * 
+   *
    * The common class of string and double is string.
-   * 
+   *
    * @return null if no common class could be found.
    */
   public static TypeInfo getCommonClass(TypeInfo a, TypeInfo b) {
@@ -581,7 +599,7 @@ public final class FunctionRegistry {
 
   /**
    * Get the GenericUDAF evaluator for the name and argumentClasses.
-   * 
+   *
    * @param name
    *          the name of the UDAF
    * @param argumentTypeInfos
@@ -605,7 +623,7 @@ public final class FunctionRegistry {
    * This method is shared between UDFRegistry and UDAFRegistry. methodName will
    * be "evaluate" for UDFRegistry, and "aggregate"/"evaluate"/"evaluatePartial"
    * for UDAFRegistry.
-   * @throws UDFArgumentException 
+   * @throws UDFArgumentException
    */
   public static <T> Method getMethodInternal(Class<? extends T> udfClass,
       String methodName, boolean exact, List<TypeInfo> argumentClasses)
@@ -768,7 +786,7 @@ public final class FunctionRegistry {
   /**
    * Gets the closest matching method corresponding to the argument list from a
    * list of methods.
-   * 
+   *
    * @param mlist
    *          The list of methods to inspect.
    * @param exact
@@ -784,7 +802,7 @@ public final class FunctionRegistry {
     List<Method> udfMethods = new ArrayList<Method>();
     // The cost of the result
     int leastConversionCost = Integer.MAX_VALUE;
-    
+
     for (Method m : mlist) {
       List<TypeInfo> argumentsAccepted = TypeInfoUtils.getParameterTypeInfos(m,
           argumentsPassed.size());
@@ -828,14 +846,14 @@ public final class FunctionRegistry {
         }
       }
     }
-    
+
     if (udfMethods.size() == 0) {
       // No matching methods found
-      throw new NoMatchingMethodException(udfClass, argumentsPassed, mlist); 
+      throw new NoMatchingMethodException(udfClass, argumentsPassed, mlist);
     }
     if (udfMethods.size() > 1) {
       // Ambiguous method found
-      throw new AmbiguousMethodException(udfClass, argumentsPassed, mlist); 
+      throw new AmbiguousMethodException(udfClass, argumentsPassed, mlist);
     }
     return udfMethods.get(0);
   }

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/GenericUDFXPath.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/GenericUDFXPath.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/GenericUDFXPath.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/GenericUDFXPath.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter;
+import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.io.Text;
+import org.w3c.dom.NodeList;
+
+@Description(
+    name = "xpath",
+    value = "_FUNC_(xml, xpath) - Returns a string array of values within xml nodes that match the xpath expression",
+    extended = "Example:\n"
+    + "  > SELECT _FUNC_('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/text()') FROM src LIMIT 1\n"
+    + "  []\n"
+    + "  > SELECT _FUNC_('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/b/text()') FROM src LIMIT 1\n"
+    + "  [\"b1\",\"b2\",\"b3\"]\n"
+    + "  > SELECT _FUNC_('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/c/text()') FROM src LIMIT 1\n"
+    + "  [\"c1\",\"c2\"]"
+    )
+public class GenericUDFXPath extends GenericUDF {
+
+  private static final List<Text> emptyResult = Collections.<Text>emptyList();
+
+  private final UDFXPathUtil xpath = new UDFXPathUtil();
+  private final List<Text> result = new ArrayList<Text>(10);
+
+  private Converter converterArg0;
+  private Converter converterArg1;
+
+  @Override
+  public ObjectInspector initialize(ObjectInspector[] arguments)
+      throws UDFArgumentException {
+    if (arguments.length != 2) {
+      throw new UDFArgumentException("Invalid number of arguments.");
+    }
+
+    converterArg0 = ObjectInspectorConverters.getConverter(arguments[0],
+        PrimitiveObjectInspectorFactory.writableStringObjectInspector);
+    converterArg1 = ObjectInspectorConverters.getConverter(arguments[1],
+        PrimitiveObjectInspectorFactory.writableStringObjectInspector);
+
+    return ObjectInspectorFactory
+        .getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
+  }
+
+  private List<Text> eval(String xml, String path) {
+    NodeList nodeList = xpath.evalNodeList(xml, path);
+    if (nodeList == null) {
+      return emptyResult;
+    }
+
+    result.clear();
+    for (int i = 0; i < nodeList.getLength(); i++) {
+      String value = nodeList.item(i).getNodeValue();
+      if (value != null) {
+        result.add(new Text(value));
+      }
+    }
+
+    return result;
+  }
+
+  @Override
+  public Object evaluate(DeferredObject[] arguments) throws HiveException {
+    assert (arguments.length == 2);
+    String xml = converterArg0.convert(arguments[0].get()).toString();
+    String path = converterArg1.convert(arguments[1].get()).toString();
+    return eval(xml, path);
+  }
+
+  @Override
+  public String getDisplayString(String[] children) {
+    StringBuilder builder = new StringBuilder();
+    builder.append("array (");
+    if (children.length > 0) {
+      builder.append("'");
+      builder.append(StringUtils.join(children, "','"));
+      builder.append("'");
+    }
+    builder.append(")");
+    return builder.toString();
+  }
+}

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathBoolean.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathBoolean.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathBoolean.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathBoolean.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+@Description(
+    name = "xpath_boolean",
+    value = "_FUNC_(xml, xpath) - Evaluates a boolean xpath expression",
+    extended = "Example:\n"
+    + "  > SELECT _FUNC_('<a><b>1</b></a>','a/b') FROM src LIMIT 1;\n"
+    + "  true\n"
+    + "  > SELECT _FUNC_('<a><b>1</b></a>','a/b = 2') FROM src LIMIT 1;\n"
+    + "  false")
+public class UDFXPathBoolean extends UDF {
+
+  private final UDFXPathUtil xpath = new UDFXPathUtil () ;
+
+  public boolean evaluate(String xml, String path) {
+    return xpath.evalBoolean(xml, path).booleanValue();
+  }
+}

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathDouble.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathDouble.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathDouble.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathDouble.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+@Description(
+    name = "xpath_number,xpath_double",
+    value = "_FUNC_(xml, xpath) - Returns a double value that matches the xpath expression",
+    extended = "Example:\n"
+    + "  > SELECT _FUNC_('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;\n"
+    + "  3.0")
+public class UDFXPathDouble extends UDF {
+
+  private final UDFXPathUtil xpath = new UDFXPathUtil();
+
+  public double evaluate(String xml, String path) {
+    return xpath.evalNumber(xml, path).doubleValue();
+  }
+}

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathFloat.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathFloat.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathFloat.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathFloat.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+@Description(
+    name = "xpath_float",
+    value = "_FUNC_(xml, xpath) - Returns a float value that matches the xpath expression",
+    extended = "Example:\n"
+    + "  > SELECT _FUNC_('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;\n"
+    + "  3.0")
+public class UDFXPathFloat extends UDF {
+
+  private final UDFXPathUtil xpath = new UDFXPathUtil();
+
+  public float evaluate(String xml, String path) {
+    return xpath.evalNumber(xml, path).floatValue();
+  }
+}

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathInteger.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathInteger.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathInteger.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathInteger.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+@Description(
+    name = "xpath_int",
+    value = "_FUNC_(xml, xpath) - Returns an integer value that matches the xpath expression",
+    extended = "Example:\n"
+    + "  > SELECT _FUNC_('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;\n"
+    + "  3")
+public class UDFXPathInteger extends UDF {
+
+  private final UDFXPathUtil xpath = new UDFXPathUtil();
+
+  public int evaluate(String xml, String path) {
+    return xpath.evalNumber(xml, path).intValue();
+  }
+}

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathLong.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathLong.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathLong.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathLong.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+@Description(
+    name = "xpath_long",
+    value = "_FUNC_(xml, xpath) - Returns a long value that matches the xpath expression",
+    extended = "Example:\n"
+    + "  > SELECT _FUNC_('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;\n"
+    + "  3")
+public class UDFXPathLong extends UDF {
+
+  private final UDFXPathUtil xpath = new UDFXPathUtil();
+
+  public long evaluate(String xml, String path) {
+    return xpath.evalNumber(xml, path).longValue();
+  }
+}

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathShort.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathShort.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathShort.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathShort.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+@Description(
+    name = "xpath_short",
+    value = "_FUNC_(xml, xpath) - Returns a short value that matches the xpath expression",
+    extended = "Example:\n"
+    + "  > SELECT _FUNC_('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;\n"
+    + "  3")
+public class UDFXPathShort extends UDF {
+
+  private final UDFXPathUtil xpath = new UDFXPathUtil();
+
+  public short evaluate(String xml, String path) {
+    return xpath.evalNumber(xml, path).shortValue();
+  }
+}

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathString.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathString.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathString.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathString.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.Text;
+
+@Description(name = "xpath_string",
+    value = "_FUNC_(xml, xpath) - Returns the text contents of the first xml node that matches the xpath expression",
+    extended = "Example:\n"
+    + "  > SELECT _FUNC_('<a><b>b</b><c>cc</c></a>','a/c') FROM src LIMIT 1;\n"
+    + "  'cc'\n"
+    + "  > SELECT _FUNC_('<a><b>b1</b><b>b2</b></a>','a/b') FROM src LIMIT 1;\n"
+    + "  'b1'\n"
+    + "  > SELECT _FUNC_('<a><b>b1</b><b>b2</b></a>','a/b[2]') FROM src LIMIT 1;\n"
+    + "  'b2'\n"
+    + "  > SELECT _FUNC_('<a><b>b1</b><b>b2</b></a>','a') FROM src LIMIT 1;\n"
+    + "  'b1b2'"
+    )
+public class UDFXPathString extends UDF {
+
+  private final UDFXPathUtil xpath = new UDFXPathUtil();
+  private final Text result = new Text();
+
+  public Text evaluate(String xml, String path) {
+    String s = xpath.evalString(xml, path);
+    if (s == null) {
+      return null;
+    }
+
+    result.set(s);
+    return result;
+  }
+}

Added: hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathUtil.java
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathUtil.java?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathUtil.java (added)
+++ hadoop/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/xml/UDFXPathUtil.java Mon Mar 15 06:09:30 2010
@@ -0,0 +1,184 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql.udf.xml;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+/**
+ * Utility class for all XPath UDFs. Each UDF instance should keep an instance
+ * of this class.
+ */
+public class UDFXPathUtil {
+  private XPath xpath = XPathFactory.newInstance().newXPath();
+  private ReusableStringReader reader = new ReusableStringReader();
+  private InputSource inputSource = new InputSource(reader);
+  private XPathExpression expression = null;
+  private String oldPath = null;
+
+  public Object eval(String xml, String path, QName qname) {
+    if (xml == null || path == null || qname == null) {
+      return null;
+    }
+
+    if (xml.length() == 0 || path.length() == 0) {
+      return null;
+    }
+
+    if (!path.equals(oldPath)) {
+      try {
+        expression = xpath.compile(path);
+      } catch (XPathExpressionException e) {
+        expression = null;
+      }
+      oldPath = path;
+    }
+
+    if (expression == null) {
+      return null;
+    }
+
+    reader.set(xml);
+
+    try {
+      return expression.evaluate(inputSource, qname);
+    } catch (XPathExpressionException e) {
+      throw new RuntimeException ("Invalid expression '" + oldPath + "'");
+    }
+  }
+
+  public Boolean evalBoolean(String xml, String path) {
+    return (Boolean) eval(xml, path, XPathConstants.BOOLEAN);
+  }
+
+  public String evalString(String xml, String path) {
+    return (String) eval(xml, path, XPathConstants.STRING);
+  }
+
+  public Double evalNumber(String xml, String path) {
+    return (Double) eval(xml, path, XPathConstants.NUMBER);
+  }
+
+  public Node evalNode(String xml, String path) {
+    return (Node) eval(xml, path, XPathConstants.NODE);
+  }
+
+  public NodeList evalNodeList(String xml, String path) {
+    return (NodeList) eval(xml, path, XPathConstants.NODESET);
+  }
+
+  /**
+   * Reusable, non-threadsafe version of {@link StringReader}.
+   */
+  public static class ReusableStringReader extends Reader {
+
+    private String str = null;
+    private int length = -1;
+    private int next = 0;
+    private int mark = 0;
+
+    public ReusableStringReader() {
+    }
+
+    public void set(String s) {
+      this.str = s;
+      this.length = s.length();
+      this.mark = 0;
+      this.next = 0;
+    }
+
+    /** Check to make sure that the stream has not been closed */
+    private void ensureOpen() throws IOException {
+      if (str == null)
+        throw new IOException("Stream closed");
+    }
+
+    public int read() throws IOException {
+      ensureOpen();
+      if (next >= length)
+        return -1;
+      return str.charAt(next++);
+    }
+
+    public int read(char cbuf[], int off, int len) throws IOException {
+      ensureOpen();
+      if ((off < 0) || (off > cbuf.length) || (len < 0)
+          || ((off + len) > cbuf.length) || ((off + len) < 0)) {
+        throw new IndexOutOfBoundsException();
+      } else if (len == 0) {
+        return 0;
+      }
+      if (next >= length)
+        return -1;
+      int n = Math.min(length - next, len);
+      str.getChars(next, next + n, cbuf, off);
+      next += n;
+      return n;
+    }
+
+    public long skip(long ns) throws IOException {
+      ensureOpen();
+      if (next >= length)
+        return 0;
+      // Bound skip by beginning and end of the source
+      long n = Math.min(length - next, ns);
+      n = Math.max(-next, n);
+      next += n;
+      return n;
+    }
+
+    public boolean ready() throws IOException {
+      ensureOpen();
+      return true;
+    }
+
+    public boolean markSupported() {
+      return true;
+    }
+
+    public void mark(int readAheadLimit) throws IOException {
+      if (readAheadLimit < 0) {
+        throw new IllegalArgumentException("Read-ahead limit < 0");
+      }
+      ensureOpen();
+      mark = next;
+    }
+
+    public void reset() throws IOException {
+      ensureOpen();
+      next = mark;
+    }
+
+    public void close() {
+      str = null;
+    }
+  }
+}

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath.q?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath.q Mon Mar 15 06:09:30 2010
@@ -0,0 +1,8 @@
+DESCRIBE FUNCTION xpath ;
+DESCRIBE FUNCTION EXTENDED xpath ;
+
+SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/text()') FROM src LIMIT 1 ;
+SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/*/text()') FROM src LIMIT 1 ;
+SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/b/text()') FROM src LIMIT 1 ;
+SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/c/text()') FROM src LIMIT 1 ;
+SELECT xpath ('<a><b class="bb">b1</b><b>b2</b><b>b3</b><c class="bb">c1</c><c>c2</c></a>', 'a/*[@class="bb"]/text()') FROM src LIMIT 1 ;
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_boolean.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_boolean.q?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_boolean.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_boolean.q Mon Mar 15 06:09:30 2010
@@ -0,0 +1,9 @@
+DESCRIBE FUNCTION xpath_boolean ;
+DESCRIBE FUNCTION EXTENDED xpath_boolean ;
+
+SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b') FROM src LIMIT 1 ;
+SELECT xpath_boolean ('<a><b>b</b></a>', 'a/c') FROM src LIMIT 1 ;
+SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b = "b"') FROM src LIMIT 1 ;
+SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b = "c"') FROM src LIMIT 1 ;
+SELECT xpath_boolean ('<a><b>10</b></a>', 'a/b < 10') FROM src LIMIT 1 ;
+SELECT xpath_boolean ('<a><b>10</b></a>', 'a/b = 10') FROM src LIMIT 1 ;

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_double.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_double.q?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_double.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_double.q Mon Mar 15 06:09:30 2010
@@ -0,0 +1,14 @@
+DESCRIBE FUNCTION xpath_number ;
+DESCRIBE FUNCTION EXTENDED xpath_number ;
+
+DESCRIBE FUNCTION xpath_double ;
+DESCRIBE FUNCTION EXTENDED xpath_double ;
+
+SELECT xpath_double ('<a>this is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_double ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_double ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1 ;
+SELECT xpath_double ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1 ;
+SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1 ;
+SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1 ;
+SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1 ;
+SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1 ;
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_float.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_float.q?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_float.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_float.q Mon Mar 15 06:09:30 2010
@@ -0,0 +1,11 @@
+DESCRIBE FUNCTION xpath_float ;
+DESCRIBE FUNCTION EXTENDED xpath_float ;
+
+SELECT xpath_float ('<a>this is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_float ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_float ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1 ;
+SELECT xpath_float ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1 ;
+SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1 ;
+SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1 ;
+SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1 ;
+SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1 ;
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_int.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_int.q?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_int.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_int.q Mon Mar 15 06:09:30 2010
@@ -0,0 +1,11 @@
+DESCRIBE FUNCTION xpath_int ;
+DESCRIBE FUNCTION EXTENDED xpath_int ;
+
+SELECT xpath_int ('<a>this is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_int ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_int ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1 ;
+SELECT xpath_int ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1 ;
+SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1 ;
+SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1 ;
+SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1 ;
+SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1 ;
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_long.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_long.q?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_long.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_long.q Mon Mar 15 06:09:30 2010
@@ -0,0 +1,11 @@
+DESCRIBE FUNCTION xpath_long ;
+DESCRIBE FUNCTION EXTENDED xpath_long ;
+
+SELECT xpath_long ('<a>this is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_long ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_long ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1 ;
+SELECT xpath_long ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1 ;
+SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1 ;
+SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1 ;
+SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1 ;
+SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1 ;

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_short.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_short.q?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_short.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_short.q Mon Mar 15 06:09:30 2010
@@ -0,0 +1,11 @@
+DESCRIBE FUNCTION xpath_short ;
+DESCRIBE FUNCTION EXTENDED xpath_short ;
+
+SELECT xpath_short ('<a>this is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_short ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_short ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1 ;
+SELECT xpath_short ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1 ;
+SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1 ;
+SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1 ;
+SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1 ;
+SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1 ;
\ No newline at end of file

Added: hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_string.q
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_string.q?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_string.q (added)
+++ hadoop/hive/trunk/ql/src/test/queries/clientpositive/udf_xpath_string.q Mon Mar 15 06:09:30 2010
@@ -0,0 +1,11 @@
+DESCRIBE FUNCTION xpath_string ;
+DESCRIBE FUNCTION EXTENDED xpath_string ;
+
+SELECT xpath_string ('<a><b>bb</b><c>cc</c></a>', 'a') FROM src LIMIT 1 ;
+SELECT xpath_string ('<a><b>bb</b><c>cc</c></a>', 'a/b') FROM src LIMIT 1 ;
+SELECT xpath_string ('<a><b>bb</b><c>cc</c></a>', 'a/c') FROM src LIMIT 1 ;
+SELECT xpath_string ('<a><b>bb</b><c>cc</c></a>', 'a/d') FROM src LIMIT 1 ;
+SELECT xpath_string ('<a><b>b1</b><b>b2</b></a>', '//b') FROM src LIMIT 1 ;
+SELECT xpath_string ('<a><b>b1</b><b>b2</b></a>', 'a/b[1]') FROM src LIMIT 1 ;
+SELECT xpath_string ('<a><b>b1</b><b>b2</b></a>', 'a/b[2]') FROM src LIMIT 1 ;
+SELECT xpath_string ('<a><b>b1</b><b id="b_2">b2</b></a>', 'a/b[@id="b_2"]') FROM src LIMIT 1 ;

Modified: hadoop/hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out?rev=923070&r1=923069&r2=923070&view=diff
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out (original)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/show_functions.q.out Mon Mar 15 06:09:30 2010
@@ -125,6 +125,15 @@ var_samp
 variance
 weekofyear
 when
+xpath
+xpath_boolean
+xpath_double
+xpath_float
+xpath_int
+xpath_long
+xpath_number
+xpath_short
+xpath_string
 year
 |
 ~
@@ -165,6 +174,7 @@ space
 to_date
 ucase
 variance
+xpath_double
 PREHOOK: query: SHOW FUNCTIONS 'log.*'
 PREHOOK: type: SHOWFUNCTIONS
 POSTHOOK: query: SHOW FUNCTIONS 'log.*'

Added: hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath.q.out?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath.q.out Mon Mar 15 06:09:30 2010
@@ -0,0 +1,62 @@
+PREHOOK: query: DESCRIBE FUNCTION xpath
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION xpath
+POSTHOOK: type: DESCFUNCTION
+xpath(xml, xpath) - Returns a string array of values within xml nodes that match the xpath expression
+PREHOOK: query: DESCRIBE FUNCTION EXTENDED xpath
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION EXTENDED xpath
+POSTHOOK: type: DESCFUNCTION
+xpath(xml, xpath) - Returns a string array of values within xml nodes that match the xpath expression
+Example:
+  > SELECT xpath('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/text()') FROM src LIMIT 1
+  []
+  > SELECT xpath('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/b/text()') FROM src LIMIT 1
+  ["b1","b2","b3"]
+  > SELECT xpath('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/c/text()') FROM src LIMIT 1
+  ["c1","c2"]
+PREHOOK: query: SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/text()') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1416181007/10000
+POSTHOOK: query: SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/text()') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1416181007/10000
+[]
+PREHOOK: query: SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/*/text()') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1851591863/10000
+POSTHOOK: query: SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/*/text()') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1851591863/10000
+["b1","b2","b3","c1","c2"]
+PREHOOK: query: SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/b/text()') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/113811557/10000
+POSTHOOK: query: SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/b/text()') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/113811557/10000
+["b1","b2","b3"]
+PREHOOK: query: SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/c/text()') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1674548693/10000
+POSTHOOK: query: SELECT xpath ('<a><b>b1</b><b>b2</b><b>b3</b><c>c1</c><c>c2</c></a>', 'a/c/text()') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1674548693/10000
+["c1","c2"]
+PREHOOK: query: SELECT xpath ('<a><b class="bb">b1</b><b>b2</b><b>b3</b><c class="bb">c1</c><c>c2</c></a>', 'a/*[@class="bb"]/text()') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/378718949/10000
+POSTHOOK: query: SELECT xpath ('<a><b class="bb">b1</b><b>b2</b><b>b3</b><c class="bb">c1</c><c>c2</c></a>', 'a/*[@class="bb"]/text()') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/378718949/10000
+["b1","c1"]

Added: hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_boolean.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_boolean.q.out?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_boolean.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_boolean.q.out Mon Mar 15 06:09:30 2010
@@ -0,0 +1,69 @@
+PREHOOK: query: DESCRIBE FUNCTION xpath_boolean
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION xpath_boolean
+POSTHOOK: type: DESCFUNCTION
+xpath_boolean(xml, xpath) - Evaluates a boolean xpath expression
+PREHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_boolean
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_boolean
+POSTHOOK: type: DESCFUNCTION
+xpath_boolean(xml, xpath) - Evaluates a boolean xpath expression
+Example:
+  > SELECT xpath_boolean('<a><b>1</b></a>','a/b') FROM src LIMIT 1;
+  true
+  > SELECT xpath_boolean('<a><b>1</b></a>','a/b = 2') FROM src LIMIT 1;
+  false
+PREHOOK: query: SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-28_114_6497232488979162957/10000
+POSTHOOK: query: SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-28_114_6497232488979162957/10000
+true
+PREHOOK: query: SELECT xpath_boolean ('<a><b>b</b></a>', 'a/c') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-34_680_245261282103280419/10000
+POSTHOOK: query: SELECT xpath_boolean ('<a><b>b</b></a>', 'a/c') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-34_680_245261282103280419/10000
+false
+PREHOOK: query: SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b = "b"') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-39_762_4463036010834055605/10000
+POSTHOOK: query: SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b = "b"') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-39_762_4463036010834055605/10000
+true
+PREHOOK: query: SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b = "c"') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-44_907_6378242213319120163/10000
+POSTHOOK: query: SELECT xpath_boolean ('<a><b>b</b></a>', 'a/b = "c"') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-44_907_6378242213319120163/10000
+false
+PREHOOK: query: SELECT xpath_boolean ('<a><b>10</b></a>', 'a/b < 10') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-49_791_1413682388477086591/10000
+POSTHOOK: query: SELECT xpath_boolean ('<a><b>10</b></a>', 'a/b < 10') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-49_791_1413682388477086591/10000
+false
+PREHOOK: query: SELECT xpath_boolean ('<a><b>10</b></a>', 'a/b = 10') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-54_878_152160286885945584/10000
+POSTHOOK: query: SELECT xpath_boolean ('<a><b>10</b></a>', 'a/b = 10') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-10_20-03-54_878_152160286885945584/10000
+true

Added: hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_double.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_double.q.out?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_double.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_double.q.out Mon Mar 15 06:09:30 2010
@@ -0,0 +1,100 @@
+PREHOOK: query: DESCRIBE FUNCTION xpath_number
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION xpath_number
+POSTHOOK: type: DESCFUNCTION
+xpath_number(xml, xpath) - Returns a double value that matches the xpath expression
+PREHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_number
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_number
+POSTHOOK: type: DESCFUNCTION
+xpath_number(xml, xpath) - Returns a double value that matches the xpath expression
+Synonyms: xpath_double
+Example:
+  > SELECT xpath_number('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;
+  3.0
+PREHOOK: query: DESCRIBE FUNCTION xpath_double
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION xpath_double
+POSTHOOK: type: DESCFUNCTION
+xpath_double(xml, xpath) - Returns a double value that matches the xpath expression
+PREHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_double
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_double
+POSTHOOK: type: DESCFUNCTION
+xpath_double(xml, xpath) - Returns a double value that matches the xpath expression
+Synonyms: xpath_number
+Example:
+  > SELECT xpath_double('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;
+  3.0
+PREHOOK: query: SELECT xpath_double ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-01_508_1991321646977894225/10000
+POSTHOOK: query: SELECT xpath_double ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-01_508_1991321646977894225/10000
+NaN
+PREHOOK: query: SELECT xpath_double ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-09_978_5086370842391754693/10000
+POSTHOOK: query: SELECT xpath_double ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-09_978_5086370842391754693/10000
+NaN
+PREHOOK: query: SELECT xpath_double ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-14_600_2112341954786715050/10000
+POSTHOOK: query: SELECT xpath_double ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-14_600_2112341954786715050/10000
+8.0E19
+PREHOOK: query: SELECT xpath_double ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-19_556_7887685109666627688/10000
+POSTHOOK: query: SELECT xpath_double ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-19_556_7887685109666627688/10000
+0.0
+PREHOOK: query: SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-25_151_3332009817772884258/10000
+POSTHOOK: query: SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-25_151_3332009817772884258/10000
+1.0
+PREHOOK: query: SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-30_323_3300427926281032367/10000
+POSTHOOK: query: SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-30_323_3300427926281032367/10000
+15.0
+PREHOOK: query: SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-38_033_4823634237013936509/10000
+POSTHOOK: query: SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-38_033_4823634237013936509/10000
+7.0
+PREHOOK: query: SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-44_959_2961106728187522931/10000
+POSTHOOK: query: SELECT xpath_double ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-18-44_959_2961106728187522931/10000
+5.0

Added: hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_float.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_float.q.out?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_float.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_float.q.out Mon Mar 15 06:09:30 2010
@@ -0,0 +1,85 @@
+PREHOOK: query: DESCRIBE FUNCTION xpath_float
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION xpath_float
+POSTHOOK: type: DESCFUNCTION
+xpath_float(xml, xpath) - Returns a float value that matches the xpath expression
+PREHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_float
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_float
+POSTHOOK: type: DESCFUNCTION
+xpath_float(xml, xpath) - Returns a float value that matches the xpath expression
+Example:
+  > SELECT xpath_float('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;
+  3.0
+PREHOOK: query: SELECT xpath_float ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/319850862/10000
+POSTHOOK: query: SELECT xpath_float ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/319850862/10000
+NaN
+PREHOOK: query: SELECT xpath_float ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1472406597/10000
+POSTHOOK: query: SELECT xpath_float ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1472406597/10000
+NaN
+PREHOOK: query: SELECT xpath_float ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1929834936/10000
+POSTHOOK: query: SELECT xpath_float ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1929834936/10000
+8.0E19
+PREHOOK: query: SELECT xpath_float ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/2143124123/10000
+POSTHOOK: query: SELECT xpath_float ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/2143124123/10000
+0.0
+PREHOOK: query: SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1347257342/10000
+POSTHOOK: query: SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1347257342/10000
+1.0
+PREHOOK: query: SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1226872791/10000
+POSTHOOK: query: SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1226872791/10000
+15.0
+PREHOOK: query: SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1024930211/10000
+POSTHOOK: query: SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1024930211/10000
+7.0
+PREHOOK: query: SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1463047098/10000
+POSTHOOK: query: SELECT xpath_float ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1463047098/10000
+5.0

Added: hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_int.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_int.q.out?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_int.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_int.q.out Mon Mar 15 06:09:30 2010
@@ -0,0 +1,85 @@
+PREHOOK: query: DESCRIBE FUNCTION xpath_int
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION xpath_int
+POSTHOOK: type: DESCFUNCTION
+xpath_int(xml, xpath) - Returns an integer value that matches the xpath expression
+PREHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_int
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_int
+POSTHOOK: type: DESCFUNCTION
+xpath_int(xml, xpath) - Returns an integer value that matches the xpath expression
+Example:
+  > SELECT xpath_int('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;
+  3
+PREHOOK: query: SELECT xpath_int ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-45-51_875_437569805026140503/10000
+POSTHOOK: query: SELECT xpath_int ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-45-51_875_437569805026140503/10000
+0
+PREHOOK: query: SELECT xpath_int ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-45-57_094_9168946979271622158/10000
+POSTHOOK: query: SELECT xpath_int ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-45-57_094_9168946979271622158/10000
+0
+PREHOOK: query: SELECT xpath_int ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-01_568_5764046814540785002/10000
+POSTHOOK: query: SELECT xpath_int ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-01_568_5764046814540785002/10000
+2147483647
+PREHOOK: query: SELECT xpath_int ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-06_220_6973728860376107951/10000
+POSTHOOK: query: SELECT xpath_int ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-06_220_6973728860376107951/10000
+0
+PREHOOK: query: SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-10_880_7033077055949838171/10000
+POSTHOOK: query: SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-10_880_7033077055949838171/10000
+1
+PREHOOK: query: SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-15_676_4494502415099433177/10000
+POSTHOOK: query: SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-15_676_4494502415099433177/10000
+15
+PREHOOK: query: SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-22_229_1539908466202895730/10000
+POSTHOOK: query: SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-22_229_1539908466202895730/10000
+7
+PREHOOK: query: SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-28_425_5182303734060221915/10000
+POSTHOOK: query: SELECT xpath_int ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-46-28_425_5182303734060221915/10000
+5

Added: hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_long.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_long.q.out?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_long.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_long.q.out Mon Mar 15 06:09:30 2010
@@ -0,0 +1,85 @@
+PREHOOK: query: DESCRIBE FUNCTION xpath_long
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION xpath_long
+POSTHOOK: type: DESCFUNCTION
+xpath_long(xml, xpath) - Returns a long value that matches the xpath expression
+PREHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_long
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_long
+POSTHOOK: type: DESCFUNCTION
+xpath_long(xml, xpath) - Returns a long value that matches the xpath expression
+Example:
+  > SELECT xpath_long('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;
+  3
+PREHOOK: query: SELECT xpath_long ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-02_746_8603604246445980017/10000
+POSTHOOK: query: SELECT xpath_long ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-02_746_8603604246445980017/10000
+0
+PREHOOK: query: SELECT xpath_long ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-08_469_245302283686945807/10000
+POSTHOOK: query: SELECT xpath_long ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-08_469_245302283686945807/10000
+0
+PREHOOK: query: SELECT xpath_long ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-13_128_903796629701395552/10000
+POSTHOOK: query: SELECT xpath_long ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-13_128_903796629701395552/10000
+9223372036854775807
+PREHOOK: query: SELECT xpath_long ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-17_475_887719902767497475/10000
+POSTHOOK: query: SELECT xpath_long ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-17_475_887719902767497475/10000
+0
+PREHOOK: query: SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-22_489_58636595447270112/10000
+POSTHOOK: query: SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-22_489_58636595447270112/10000
+1
+PREHOOK: query: SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-27_102_7513620137103622420/10000
+POSTHOOK: query: SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-27_102_7513620137103622420/10000
+15
+PREHOOK: query: SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-37_776_6632052997392146833/10000
+POSTHOOK: query: SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-37_776_6632052997392146833/10000
+7
+PREHOOK: query: SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-43_979_587396224869265022/10000
+POSTHOOK: query: SELECT xpath_long ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/scratchdir/hive_2010-03-11_06-38-43_979_587396224869265022/10000
+5

Added: hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_short.q.out
URL: http://svn.apache.org/viewvc/hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_short.q.out?rev=923070&view=auto
==============================================================================
--- hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_short.q.out (added)
+++ hadoop/hive/trunk/ql/src/test/results/clientpositive/udf_xpath_short.q.out Mon Mar 15 06:09:30 2010
@@ -0,0 +1,85 @@
+PREHOOK: query: DESCRIBE FUNCTION xpath_short
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION xpath_short
+POSTHOOK: type: DESCFUNCTION
+xpath_short(xml, xpath) - Returns a short value that matches the xpath expression
+PREHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_short
+PREHOOK: type: DESCFUNCTION
+POSTHOOK: query: DESCRIBE FUNCTION EXTENDED xpath_short
+POSTHOOK: type: DESCFUNCTION
+xpath_short(xml, xpath) - Returns a short value that matches the xpath expression
+Example:
+  > SELECT xpath_short('<a><b>1</b><b>2</b></a>','sum(a/b)') FROM src LIMIT 1;
+  3
+PREHOOK: query: SELECT xpath_short ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/43003016/10000
+POSTHOOK: query: SELECT xpath_short ('<a>this is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/43003016/10000
+0
+PREHOOK: query: SELECT xpath_short ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/420344977/10000
+POSTHOOK: query: SELECT xpath_short ('<a>this 2 is not a number</a>', 'a') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/420344977/10000
+0
+PREHOOK: query: SELECT xpath_short ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/542896770/10000
+POSTHOOK: query: SELECT xpath_short ('<a><b>2000000000</b><c>40000000000</c></a>', 'a/b * a/c') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/542896770/10000
+-1
+PREHOOK: query: SELECT xpath_short ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1699233281/10000
+POSTHOOK: query: SELECT xpath_short ('<a>try a boolean</a>', 'a = 10') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1699233281/10000
+0
+PREHOOK: query: SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1504264750/10000
+POSTHOOK: query: SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'a/b') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1504264750/10000
+1
+PREHOOK: query: SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1166661278/10000
+POSTHOOK: query: SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/*)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1166661278/10000
+15
+PREHOOK: query: SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/633201724/10000
+POSTHOOK: query: SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b)') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/633201724/10000
+7
+PREHOOK: query: SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+PREHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1825578599/10000
+POSTHOOK: query: SELECT xpath_short ('<a><b class="odd">1</b><b class="even">2</b><b class="odd">4</b><c>8</c></a>', 'sum(a/b[@class="odd"])') FROM src LIMIT 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+POSTHOOK: Output: file:/Users/patrick/Documents/workspace/hive-trunk/build/ql/tmp/1825578599/10000
+5



Mime
View raw message