You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by pv...@apache.org on 2019/01/25 10:51:37 UTC

hive git commit: HIVE-21134: Hive Build Version as UDF (Mani M via Peter Vary)

Repository: hive
Updated Branches:
  refs/heads/master 969d96d23 -> 20d9306e9


HIVE-21134: Hive Build Version as UDF (Mani M via Peter Vary)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/20d9306e
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/20d9306e
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/20d9306e

Branch: refs/heads/master
Commit: 20d9306e954c0cbefb0fe6dbaaba95104b922ea3
Parents: 969d96d
Author: Mani M <rm...@gmail.com>
Authored: Fri Jan 25 11:49:53 2019 +0100
Committer: Peter Vary <pv...@cloudera.com>
Committed: Fri Jan 25 11:51:28 2019 +0100

----------------------------------------------------------------------
 .../hadoop/hive/ql/exec/FunctionRegistry.java   |  2 ++
 .../hadoop/hive/ql/udf/UDFBuildVersion.java     | 38 ++++++++++++++++++++
 .../hadoop/hive/ql/udf/TestUDFBuildVersion.java | 36 +++++++++++++++++++
 .../results/clientpositive/show_functions.q.out |  1 +
 4 files changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/20d9306e/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
index bbe7fb0..e7aa041 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/FunctionRegistry.java
@@ -46,6 +46,7 @@ import org.apache.hadoop.hive.ql.udf.UDFAsin;
 import org.apache.hadoop.hive.ql.udf.UDFAtan;
 import org.apache.hadoop.hive.ql.udf.UDFBase64;
 import org.apache.hadoop.hive.ql.udf.UDFBin;
+import org.apache.hadoop.hive.ql.udf.UDFBuildVersion;
 import org.apache.hadoop.hive.ql.udf.UDFChr;
 import org.apache.hadoop.hive.ql.udf.UDFConv;
 import org.apache.hadoop.hive.ql.udf.UDFCos;
@@ -394,6 +395,7 @@ public final class FunctionRegistry {
 
     // Utility UDFs
     system.registerUDF("version", UDFVersion.class, false);
+    system.registerUDF("buildversion", UDFBuildVersion.class, false);
 
     // Aliases for Java Class Names
     // These are used in getImplicitConvertUDFMethod

http://git-wip-us.apache.org/repos/asf/hive/blob/20d9306e/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFBuildVersion.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFBuildVersion.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFBuildVersion.java
new file mode 100644
index 0000000..135e0bc
--- /dev/null
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFBuildVersion.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.Text;
+import org.apache.hive.common.util.HiveVersionInfo;
+
+/**
+ * Source for UDFBuildVersion.
+ */
+@Description(name = "buildversion",
+    value = "_FUNC_() - Returns the Hive build version string - includes base" +
+    "version, revision, User, Source Check Sum")
+public class UDFBuildVersion extends UDF {
+  private static final String VERSIONINFO = String.format("%s", HiveVersionInfo.getBuildVersion());
+
+  public Text evaluate() {
+    return new Text(VERSIONINFO);
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/20d9306e/ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFBuildVersion.java
----------------------------------------------------------------------
diff --git a/ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFBuildVersion.java b/ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFBuildVersion.java
new file mode 100644
index 0000000..d54afbd
--- /dev/null
+++ b/ql/src/test/org/apache/hadoop/hive/ql/udf/TestUDFBuildVersion.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import org.apache.hadoop.io.Text;
+import org.apache.hive.common.util.HiveVersionInfo;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit Test Case for UDFBuildVersion.
+ */
+public class TestUDFBuildVersion extends TestCase {
+  public void testVersion() {
+    UDFBuildVersion udf = new UDFBuildVersion();
+    Text result = udf.evaluate();
+    String expected = String.format("%s", HiveVersionInfo.getBuildVersion());
+    assertEquals(expected, result.toString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/20d9306e/ql/src/test/results/clientpositive/show_functions.q.out
----------------------------------------------------------------------
diff --git a/ql/src/test/results/clientpositive/show_functions.q.out b/ql/src/test/results/clientpositive/show_functions.q.out
index 0fdcbda..c9716e9 100644
--- a/ql/src/test/results/clientpositive/show_functions.q.out
+++ b/ql/src/test/results/clientpositive/show_functions.q.out
@@ -41,6 +41,7 @@ bin
 bloom_filter
 bround
 bucket_number
+buildversion
 cardinality_violation
 case
 cbrt