Index: build.xml
===================================================================
--- build.xml (revision 228410)
+++ build.xml (working copy)
@@ -237,6 +237,9 @@
+
+
+
Index: bin/hive
===================================================================
--- bin/hive (revision 214319)
+++ bin/hive (working copy)
@@ -42,6 +42,10 @@
HELP=_help
shift
;;
+ --version)
+ VERSION=_version
+ shift
+ ;;
--debug*)
DEBUG=$1
shift
@@ -55,7 +59,9 @@
if [ "$SERVICE" = "" ] ; then
if [ "$HELP" = "_help" ] ; then
SERVICE="help"
- else
+ elif [ "$VERSION" = "_version" ] ; then
+ SERVICE="version"
+ else
SERVICE="cli"
fi
fi
@@ -187,7 +193,7 @@
exit 5
fi
-if [ "$hadoop_major_ver" -lt "1" -a "$hadoop_minor_ver$hadoop_patch_ver" -lt "201" ]; then
+if [ "$hadoop_major_ver" -lt "0" -a "$hadoop_minor_ver$hadoop_patch_ver" -lt "191" ]; then
echo "Hive requires Hadoop 0.20.x (x >= 1)."
echo "'hadoop version' returned:"
echo `$HADOOP version`
@@ -223,6 +229,10 @@
for j in $SERVICE_LIST ; do
if [ "$j" = "$SERVICE" ] ; then
TORUN=${j}$HELP
+ if [ "$j" = "version" ]; then
+ echo "--- Hadoop Version ---"
+ $HADOOP version
+ fi
fi
done
Index: bin/ext/version.sh
===================================================================
--- bin/ext/version.sh (revision 0)
+++ bin/ext/version.sh (working copy)
@@ -0,0 +1,29 @@
+# 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.
+
+THISSERVICE=version
+export SERVICE_LIST="${SERVICE_LIST}${THISSERVICE} "
+
+version () {
+ CLASS=org.apache.hadoop.hive.ql.util.HiveVersionInfo
+ echo "--- Hive Version ---"
+ execHiveCmd $CLASS "$@"
+}
+
+version_help () {
+ CLASS=org.apache.hadoop.hive.ql.util.HiveVersionInfo
+ execHiveCmd $CLASS "--help"
+}
+
Index: ql/src/saveVersion.sh
===================================================================
--- ql/src/saveVersion.sh (revision 0)
+++ ql/src/saveVersion.sh (working copy)
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# 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.
+
+
+# This file is used to generate the BuildStamp.java class that
+# records the user, url, revision and timestamp.
+unset LANG
+unset LC_CTYPE
+version=$1
+user=`whoami`
+date=`date`
+if [ -d .git ]; then
+ revision=`git log -1 --pretty=oneline | awk '{print $1}'`
+ hostname=`git remote -v | head -n1 | awk '{print $2}'`
+ branch=`git branch | sed -n -e 's/^* //p'`
+ url="$hostname on branch $branch"
+else
+ revision=`svn info | sed -n -e 's/Last Changed Rev: \(.*\)/\1/p'`
+ url=`svn info | sed -n -e 's/URL: \(.*\)/\1/p'`
+fi
+mkdir -p ql/src/java/org/apache/hadoop/hive
+cat << EOF | \
+ sed -e "s/VERSION/$version/" -e "s/USER/$user/" -e "s/DATE/$date/" \
+ -e "s|URL|$url|" -e "s/REV/$revision/" \
+ > ql/src/java/org/apache/hadoop/hive/package-info.java
+/**
+ * Generated by src/saveVersion.sh
+ */
+@HiveVersionAnnotation(version="VERSION", revision="REV",
+ user="USER", date="DATE", url="URL")
+package org.apache.hadoop.hive;
+EOF
Index: ql/src/java/org/apache/hadoop/hive/HiveVersionAnnotation.java
===================================================================
--- ql/src/java/org/apache/hadoop/hive/HiveVersionAnnotation.java (revision 0)
+++ ql/src/java/org/apache/hadoop/hive/HiveVersionAnnotation.java (working copy)
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A package attribute that captures the version of Hive that was compiled.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PACKAGE)
+public @interface HiveVersionAnnotation {
+
+ /**
+ * Get the Hadoop version
+ * @return the version string, eg. "0.11-SNAPSHOT"
+ */
+ String version();
+
+ /**
+ * Get the username that compiled Hadoop.
+ */
+ String user();
+
+ /**
+ * Get the date when Hadoop was compiled.
+ * @return the date in unix 'date' format
+ */
+ String date();
+
+ /**
+ * Get the url for the subversion repository.
+ */
+ String url();
+
+ /**
+ * Get the subversion revision.
+ * @return the revision number as a string (eg. "451451")
+ */
+ String revision();
+}
\ No newline at end of file
Index: ql/src/java/org/apache/hadoop/hive/ql/util/HiveVersionInfo.java
===================================================================
--- ql/src/java/org/apache/hadoop/hive/ql/util/HiveVersionInfo.java (revision 0)
+++ ql/src/java/org/apache/hadoop/hive/ql/util/HiveVersionInfo.java (working copy)
@@ -0,0 +1,99 @@
+/*
+ * 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.util;
+
+import org.apache.hadoop.hive.HiveVersionAnnotation;
+
+/**
+ * This class finds the package info for Hadoop and the HadoopVersionAnnotation
+ * information.
+ */
+public class HiveVersionInfo {
+ private static Package myPackage;
+ private static HiveVersionAnnotation version;
+
+ static {
+ myPackage = HiveVersionAnnotation.class.getPackage();
+ version = myPackage.getAnnotation(HiveVersionAnnotation.class);
+ }
+
+ /**
+ * Get the meta-data for the Hadoop package.
+ * @return
+ */
+ static Package getPackage() {
+ return myPackage;
+ }
+
+ /**
+ * Get the Hadoop version.
+ * @return the Hadoop version string, eg. "0.11-SNAPSHOT"
+ */
+ public static String getVersion() {
+ return version != null ? version.version() : "Unknown";
+ }
+
+ /**
+ * Get the subversion revision number for the root directory
+ * @return the revision number, eg. "451451"
+ */
+ public static String getRevision() {
+ return version != null ? version.revision() : "Unknown";
+ }
+
+ /**
+ * The date that Hadoop was compiled.
+ * @return the compilation date in unix date format
+ */
+ public static String getDate() {
+ return version != null ? version.date() : "Unknown";
+ }
+
+ /**
+ * The user that compiled Hadoop.
+ * @return the username of the user
+ */
+ public static String getUser() {
+ return version != null ? version.user() : "Unknown";
+ }
+
+ /**
+ * Get the subversion URL for the root Hadoop directory.
+ */
+ public static String getUrl() {
+ return version != null ? version.url() : "Unknown";
+ }
+
+ /**
+ * Returns the buildVersion which includes version,
+ * revision, user and date.
+ */
+ public static String getBuildVersion(){
+ return HiveVersionInfo.getVersion() +
+ " from " + HiveVersionInfo.getRevision() +
+ " by " + HiveVersionInfo.getUser() +
+ " on " + HiveVersionInfo.getDate();
+ }
+
+ public static void main(String[] args) {
+ System.out.println("Hive " + getVersion());
+ System.out.println("Subversion " + getUrl() + " -r " + getRevision());
+ System.out.println("Compiled by " + getUser() + " on " + getDate());
+ }
+}
\ No newline at end of file