diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java index 641abab..d092865 100644 --- itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java +++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java @@ -2871,6 +2871,11 @@ private void createTable(String dbName, String tableName) @Test public void testTransactionalValidation() throws Throwable { + String dbName = "acidDb"; + silentDropDatabase(dbName); + Database db = new Database(); + db.setName(dbName); + client.createDatabase(db); String tblName = "acidTable"; String owner = "acid"; Map fields = new HashMap(); @@ -2892,7 +2897,7 @@ public void testTransactionalValidation() throws Throwable { // Fail - No "transactional" property is specified try { - Table t = createTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, owner, params, null, sd, 0); + Table t = createTable(dbName, tblName, owner, params, null, sd, 0); Assert.assertTrue("Expected exception", false); } catch (MetaException e) { Assert.assertEquals("'transactional' property of TBLPROPERTIES may only have value 'true'", e.getMessage()); @@ -2902,7 +2907,7 @@ public void testTransactionalValidation() throws Throwable { try { params.clear(); params.put("transactional", "foobar"); - Table t = createTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, owner, params, null, sd, 0); + Table t = createTable(dbName, tblName, owner, params, null, sd, 0); Assert.assertTrue("Expected exception", false); } catch (MetaException e) { Assert.assertEquals("'transactional' property of TBLPROPERTIES may only have value 'true'", e.getMessage()); @@ -2912,7 +2917,7 @@ public void testTransactionalValidation() throws Throwable { try { params.clear(); params.put("transactional", "true"); - Table t = createTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, owner, params, null, sd, 0); + Table t = createTable(dbName, tblName, owner, params, null, sd, 0); Assert.assertTrue("Expected exception", false); } catch (MetaException e) { Assert.assertEquals("The table must be bucketed and stored using an ACID compliant format (such as ORC)", e.getMessage()); @@ -2925,7 +2930,7 @@ public void testTransactionalValidation() throws Throwable { List bucketCols = new ArrayList(); bucketCols.add("income"); sd.setBucketCols(bucketCols); - Table t = createTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, owner, params, null, sd, 0); + Table t = createTable(dbName, tblName, owner, params, null, sd, 0); Assert.assertTrue("Expected exception", false); } catch (MetaException e) { Assert.assertEquals("The table must be bucketed and stored using an ACID compliant format (such as ORC)", e.getMessage()); @@ -2939,7 +2944,7 @@ public void testTransactionalValidation() throws Throwable { sd.setBucketCols(bucketCols); sd.setInputFormat("org.apache.hadoop.hive.ql.io.orc.OrcInputFormat"); sd.setOutputFormat("org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat"); - Table t = createTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, owner, params, null, sd, 0); + Table t = createTable(dbName, tblName, owner, params, null, sd, 0); Assert.assertTrue("CREATE TABLE should succeed", "true".equals(t.getParameters().get(hive_metastoreConstants.TABLE_IS_TRANSACTIONAL))); /// ALTER TABLE scenarios @@ -2950,7 +2955,7 @@ public void testTransactionalValidation() throws Throwable { params.put("transactional", "false"); t = new Table(); t.setParameters(params); - client.alter_table(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, t); + client.alter_table(dbName, tblName, t); Assert.assertTrue("Expected exception", false); } catch (MetaException e) { Assert.assertEquals("TBLPROPERTIES with 'transactional'='true' cannot be unset", e.getMessage()); @@ -2961,10 +2966,10 @@ public void testTransactionalValidation() throws Throwable { tblName += "1"; params.clear(); sd.unsetBucketCols(); - t = createTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, owner, params, null, sd, 0); + t = createTable(dbName, tblName, owner, params, null, sd, 0); params.put("transactional", "true"); t.setParameters(params); - client.alter_table(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, t); + client.alter_table(dbName, tblName, t); Assert.assertTrue("Expected exception", false); } catch (MetaException e) { Assert.assertEquals("The table must be bucketed and stored using an ACID compliant format (such as ORC)", e.getMessage()); @@ -2975,11 +2980,11 @@ public void testTransactionalValidation() throws Throwable { params.clear(); sd.setNumBuckets(1); sd.setBucketCols(bucketCols); - t = createTable(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, owner, params, null, sd, 0); + t = createTable(dbName, tblName, owner, params, null, sd, 0); params.put("transactional", "true"); t.setParameters(params); t.setPartitionKeys(Collections.EMPTY_LIST); - client.alter_table(MetaStoreUtils.DEFAULT_DATABASE_NAME, tblName, t); + client.alter_table(dbName, tblName, t); Assert.assertTrue("ALTER TABLE should succeed", "true".equals(t.getParameters().get(hive_metastoreConstants.TABLE_IS_TRANSACTIONAL))); }