hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject [1/2] hive git commit: HIVE-13025 : need a better error message for when one needs to run schematool (Sergey Shelukhin, reviewed by Prasanth Jayachandran, Sushanth Sowmyan, Alan Gates)
Date Tue, 09 Feb 2016 01:52:42 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-2.0 4357f130c -> ecccdda84
  refs/heads/master 4fa0f6659 -> 2a0dc3c3f


HIVE-13025 : need a better error message for when one needs to run schematool (Sergey Shelukhin,
reviewed by Prasanth Jayachandran, Sushanth Sowmyan, Alan Gates)

Conflicts:
	ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java


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

Branch: refs/heads/master
Commit: 2a0dc3c3ff4ac914a967bd62d90ba9801cc04c57
Parents: 4fa0f66
Author: Sergey Shelukhin <sershe@apache.org>
Authored: Mon Feb 8 15:39:32 2016 -0800
Committer: Sergey Shelukhin <sershe@apache.org>
Committed: Mon Feb 8 17:43:32 2016 -0800

----------------------------------------------------------------------
 .../apache/hadoop/hive/ql/metadata/Hive.java    | 28 +++++++++++++++++++-
 .../hadoop/hive/ql/session/SessionState.java    |  6 +++++
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/2a0dc3c3/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
index 75d2519..5c32f6f 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java
@@ -45,6 +45,8 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import com.google.common.collect.ImmutableMap;
+import javax.jdo.JDODataStoreException;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -3125,6 +3127,13 @@ private void constructOneLBLocationMap(FileStatus fSta,
     }
   }
 
+  public static class SchemaException extends MetaException {
+    private static final long serialVersionUID = 1L;
+    public SchemaException(String message) {
+      super(message);
+    }
+  }
+
   /**
    * @return the metastore client for the current thread
    * @throws MetaException
@@ -3140,7 +3149,24 @@ private void constructOneLBLocationMap(FileStatus fSta,
         LOG.error(msg, e);
         throw new MetaException(msg + "\n" + StringUtils.stringifyException(e));
       }
-      metaStoreClient = createMetaStoreClient();
+      try {
+        metaStoreClient = createMetaStoreClient();
+      } catch (RuntimeException ex) {
+        Throwable t = ex.getCause();
+        while (t != null) {
+          if (t instanceof JDODataStoreException && t.getMessage() != null
+              && t.getMessage().contains("autoCreate")) {
+            LOG.error("Cannot initialize metastore due to autoCreate error", t);
+            // DataNucleus wants us to auto-create, but we shall do no such thing.
+            throw new SchemaException("Hive metastore database is not initialized. Please
use "
+              + "schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema.
If "
+              + "needed, don't forget to include the option to auto-create the underlying
database"
+              + " in your JDBC connection string (e.g. ?createDatabaseIfNotExist=true for
mysql)");
+          }
+          t = t.getCause();
+        }
+        throw ex;
+      }
       String metaStoreUris = conf.getVar(HiveConf.ConfVars.METASTOREURIS);
       if (!org.apache.commons.lang3.StringUtils.isEmpty(metaStoreUris)) {
         // get a synchronized wrapper if the meta store is remote.

http://git-wip-us.apache.org/repos/asf/hive/blob/2a0dc3c3/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
index 15965ad..2a1458e 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
@@ -551,6 +551,12 @@ public class SessionState {
           throw new RuntimeException(e);
         }
       }
+    } catch (RuntimeException e) {
+      throw e;
+    } catch (Hive.SchemaException e) {
+      RuntimeException ex = new RuntimeException(e.getMessage());
+      ex.setStackTrace(new StackTraceElement[0]);
+      throw ex;
     } catch (Exception e) {
       // Catch-all due to some exec time dependencies on session state
       // that would cause ClassNoFoundException otherwise


Mime
View raw message