diff --git standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java index 5819a2699c..1327fa267f 100644 --- standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java +++ standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java @@ -1774,6 +1774,11 @@ private void create_table_core(final RawStore ms, final Table tbl, List checkConstraints) throws AlreadyExistsException, MetaException, InvalidObjectException, NoSuchObjectException { + // 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"); diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java index c40b42ab48..efa3e7c8b4 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java @@ -367,7 +367,7 @@ public void testCreateTableDefaultValuesView() throws Exception { createdTable.getSd().getLocation()); } - @Test(expected = InvalidObjectException.class) + @Test(expected = MetaException.class) public void testCreateTableNullDatabase() throws Exception { Table table = testTables[0]; table.setDbName(null);