This is an automated email from the ASF dual-hosted git repository.

ngangam pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git

commit 4779e8680a05272f258375086e3fefcbd01ca3f0
Author: Naveen Gangam <ngan...@cloudera.com>
AuthorDate: Tue Dec 1 11:03:24 2020 -0500

    HIVE-24396: Fix to CachedStore to make DBs NATIVE and fix to 
create_table_core on null DBs
---
 .../apache/hadoop/hive/metastore/HiveMetaStore.java   | 19 ++++++++++---------
 .../hadoop/hive/metastore/cache/CachedStore.java      |  3 +++
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
index 7288ca3..26552d1 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java
@@ -2366,6 +2366,16 @@ public class HiveMetaStore extends ThriftHiveMetastore {
       List<String> processorCapabilities = req.getProcessorCapabilities();
       String processorId = req.getProcessorIdentifier();
 
+      // To preserve backward compatibility throw MetaException in case of 
null database
+      if (tbl.getDbName() == null) {
+        throw new MetaException("Null database name is not allowed");
+      }
+
+      if (!MetaStoreUtils.validateName(tbl.getTableName(), conf)) {
+        throw new InvalidObjectException(tbl.getTableName()
+            + " is not a valid object name");
+      }
+
       Database db = get_database_core(tbl.getCatName(), tbl.getDbName());
       if (db != null && db.getType().equals(DatabaseType.REMOTE)) {
         
DataConnectorProviderFactory.getDataConnectorProvider(db).createTable(tbl);
@@ -2384,15 +2394,6 @@ public class HiveMetaStore extends ThriftHiveMetastore {
         tbl.unsetColStats();
       }
 
-      // To preserve backward compatibility throw MetaException in case of 
null database
-      if (tbl.getDbName() == null) {
-        throw new MetaException("Null database name is not allowed");
-      }
-
-      if (!MetaStoreUtils.validateName(tbl.getTableName(), conf)) {
-        throw new InvalidObjectException(tbl.getTableName()
-            + " is not a valid object name");
-      }
       String validate = 
MetaStoreServerUtils.validateTblColumns(tbl.getSd().getCols());
       if (validate != null) {
         throw new InvalidObjectException("Invalid column " + validate);
diff --git 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
index 8ddaf4c..0a0f8fd 100644
--- 
a/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
+++ 
b/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/cache/CachedStore.java
@@ -1102,6 +1102,9 @@ public class CachedStore implements RawStore, 
Configurable {
   }
 
   @Override public void createDatabase(Database db) throws 
InvalidObjectException, MetaException {
+    if (db.getType() == null) {
+      db.setType(DatabaseType.NATIVE);
+    }
     rawStore.createDatabase(db);
     // in case of event based cache update, cache will be updated during 
commit.
     if (!canUseEvents) {

Reply via email to