You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/01/20 17:21:47 UTC

[GitHub] [hive] nrg4878 commented on a change in pull request #2924: HIVE-25826: Support table default types at each database level

nrg4878 commented on a change in pull request #2924:
URL: https://github.com/apache/hive/pull/2924#discussion_r788817323



##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDatabaseTableDefault.java
##########
@@ -0,0 +1,304 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.hive.common.FileUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.LockState;
+import org.apache.hadoop.hive.metastore.api.LockType;
+import org.apache.hadoop.hive.metastore.api.ShowCompactRequest;
+import org.apache.hadoop.hive.metastore.api.ShowCompactResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksRequest;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponseElement;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.metastore.utils.TestTxnDbUtil;
+import org.apache.hadoop.hive.metastore.txn.TxnStore;
+import org.apache.hadoop.hive.metastore.txn.TxnUtils;
+import org.apache.hadoop.hive.ql.exec.AbstractFileMergeOperator;
+import org.apache.hadoop.hive.ql.io.BucketCodec;
+import org.apache.hadoop.hive.ql.io.HiveInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.OrcFile;
+import org.apache.hadoop.hive.ql.io.orc.OrcInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.Reader;
+import org.apache.hadoop.hive.ql.lockmgr.TestDbTxnManager2;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.orc.OrcProto;
+import org.apache.tez.mapreduce.hadoop.MRJobConfig;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+//import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+/**
+ * This class resides in itests to facilitate running query using Tez engine, since the jars are
+ * fully loaded here, which is not the case if it stays in ql.
+ */
+public class TestDatabaseTableDefault {
+    static final private Logger LOG = LoggerFactory.getLogger(TestDatabaseTableDefault.class);
+
+    private HiveConf hiveConf;
+    private IDriver d;
+    private String database_with_default_table_type = "database_with_default_table_type";
+    private String default_db = "default_db";
+    private String table_type_managed = "MANAGED_TABLE";
+    private String table_type_external = "EXTERNAL_TABLE";
+    File ext_wh = null;
+    File wh = null;
+    protected static HiveMetaStoreClient client;
+    protected static Configuration conf;
+    private static enum TableNames {
+        TRANSACTIONALTBL1("transactional_table_1"),
+        TRANSACTIONALTBL2("transactional_table_2"),
+        TRANSACTIONALTBL3("transactional_table_3"),
+        TRANSACTIONALTBL4("transactional_table_4"),
+        TRANSACTIONALTBL5("transactional_table_5"),
+        TRANSACTIONALTBL6("transactional_table_6"),
+        EXTERNALTABLE1("external_table_1"),
+        EXTERNALTABLE2("external_table_2"),
+        EXTERNALTABLE3("external_table_3"),
+        EXTERNALTABLE4("external_table_4"),
+        EXTERNALTABLE5("external_table_5"),
+        NONACIDPART("nonAcidPart"),
+        NONACIDNONBUCKET("nonAcidNonBucket");
+
+        private final String name;
+        @Override
+        public String toString() {
+            return name;
+        }
+        TableNames(String name) {
+            this.name = name;
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        hiveConf = new HiveConf(this.getClass());
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.CREATE_TABLES_AS_ACID, true);
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_CREATE_TABLES_AS_INSERT_ONLY, true);
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, true);
+        hiveConf.set(HiveConf.ConfVars.HIVEDEFAULTMANAGEDFILEFORMAT.varname, "ORC");
+        hiveConf.setVar(HiveConf.ConfVars.HIVE_TXN_MANAGER, DbTxnManager.class.getName());
+        hiveConf.set(HiveConf.ConfVars.METASTORE_CLIENT_CAPABILITIES.varname, "HIVEFULLACIDREAD,HIVEFULLACIDWRITE,HIVECACHEINVALIDATE,HIVEMANAGESTATS,HIVEMANAGEDINSERTWRITE,HIVEMANAGEDINSERTREAD");
+        TestTxnDbUtil.setConfValues(hiveConf);
+        TestTxnDbUtil.prepDb(hiveConf);
+
+        SessionState.start(new SessionState(hiveConf));
+        d = DriverFactory.newDriver(hiveConf);
+
+        conf = MetastoreConf.newMetastoreConf();

Review comment:
       shouldnt you be using the same configuration object as above? "hiveconf"

##########
File path: standalone-metastore/metastore-common/src/main/thrift/hive_metastore.thrift
##########
@@ -3106,4 +3106,5 @@ const string JDBC_CONFIG_PREFIX = "hive.sql.",
 const string TABLE_IS_CTAS = "created_with_ctas",
 const string PARTITION_TRANSFORM_SPEC = "partition_transform_spec",
 const string NO_CLEANUP = "no_cleanup",
-const string CTAS_LEGACY_CONFIG = "create_table_as_external",
\ No newline at end of file
+const string CTAS_LEGACY_CONFIG = "create_table_as_external",
+const string DEFAULT_TABLE_TYPE = "defaultTableType",

Review comment:
       This constant is not used by HMS code at this point right? we should remove this from the thrift definition file. This will reduce the size of the fix as well.

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
##########
@@ -13600,7 +13616,12 @@ ASTNode analyzeCreateTable(
 
     // Handle different types of CREATE TABLE command
     // Note: each branch must call addDbAndTabToOutputs after finalizing table properties.
-
+    Database database  = getDatabase(qualifiedTabName.getDb());
+    boolean isDefaultTableTypeChanged = false;
+    if(database.getParameters() != null && database.getParameters().containsKey(DEFAULT_TABLE_TYPE) && database.getParameters().get(DEFAULT_TABLE_TYPE).equalsIgnoreCase("external")) {
+      isExt = true;
+      isDefaultTableTypeChanged = true;

Review comment:
       appears the logic when "defaultTableType=ACID" is not implemented. I do not see where we check for this and convert to ACID automatically.

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDatabaseTableDefault.java
##########
@@ -0,0 +1,304 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.LocatedFileStatus;

Review comment:
       same here. please remove all unnecessary imports (IDE can help with that)

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDatabaseTableDefault.java
##########
@@ -0,0 +1,304 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.hive.common.FileUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.LockState;
+import org.apache.hadoop.hive.metastore.api.LockType;
+import org.apache.hadoop.hive.metastore.api.ShowCompactRequest;
+import org.apache.hadoop.hive.metastore.api.ShowCompactResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksRequest;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponseElement;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.metastore.utils.TestTxnDbUtil;
+import org.apache.hadoop.hive.metastore.txn.TxnStore;
+import org.apache.hadoop.hive.metastore.txn.TxnUtils;
+import org.apache.hadoop.hive.ql.exec.AbstractFileMergeOperator;
+import org.apache.hadoop.hive.ql.io.BucketCodec;
+import org.apache.hadoop.hive.ql.io.HiveInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.OrcFile;
+import org.apache.hadoop.hive.ql.io.orc.OrcInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.Reader;
+import org.apache.hadoop.hive.ql.lockmgr.TestDbTxnManager2;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.orc.OrcProto;
+import org.apache.tez.mapreduce.hadoop.MRJobConfig;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+//import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+/**
+ * This class resides in itests to facilitate running query using Tez engine, since the jars are
+ * fully loaded here, which is not the case if it stays in ql.
+ */
+public class TestDatabaseTableDefault {
+    static final private Logger LOG = LoggerFactory.getLogger(TestDatabaseTableDefault.class);
+
+    private HiveConf hiveConf;
+    private IDriver d;
+    private String database_with_default_table_type = "database_with_default_table_type";
+    private String default_db = "default_db";
+    private String table_type_managed = "MANAGED_TABLE";
+    private String table_type_external = "EXTERNAL_TABLE";

Review comment:
       make these string constants "static final".

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDatabaseTableDefault.java
##########
@@ -0,0 +1,304 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.hive.common.FileUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.LockState;
+import org.apache.hadoop.hive.metastore.api.LockType;
+import org.apache.hadoop.hive.metastore.api.ShowCompactRequest;
+import org.apache.hadoop.hive.metastore.api.ShowCompactResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksRequest;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponseElement;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.metastore.utils.TestTxnDbUtil;
+import org.apache.hadoop.hive.metastore.txn.TxnStore;
+import org.apache.hadoop.hive.metastore.txn.TxnUtils;
+import org.apache.hadoop.hive.ql.exec.AbstractFileMergeOperator;
+import org.apache.hadoop.hive.ql.io.BucketCodec;
+import org.apache.hadoop.hive.ql.io.HiveInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.OrcFile;
+import org.apache.hadoop.hive.ql.io.orc.OrcInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.Reader;
+import org.apache.hadoop.hive.ql.lockmgr.TestDbTxnManager2;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.orc.OrcProto;
+import org.apache.tez.mapreduce.hadoop.MRJobConfig;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+//import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+/**
+ * This class resides in itests to facilitate running query using Tez engine, since the jars are
+ * fully loaded here, which is not the case if it stays in ql.
+ */
+public class TestDatabaseTableDefault {
+    static final private Logger LOG = LoggerFactory.getLogger(TestDatabaseTableDefault.class);
+
+    private HiveConf hiveConf;
+    private IDriver d;
+    private String database_with_default_table_type = "database_with_default_table_type";
+    private String default_db = "default_db";
+    private String table_type_managed = "MANAGED_TABLE";
+    private String table_type_external = "EXTERNAL_TABLE";
+    File ext_wh = null;
+    File wh = null;
+    protected static HiveMetaStoreClient client;
+    protected static Configuration conf;
+    private static enum TableNames {
+        TRANSACTIONALTBL1("transactional_table_1"),
+        TRANSACTIONALTBL2("transactional_table_2"),
+        TRANSACTIONALTBL3("transactional_table_3"),
+        TRANSACTIONALTBL4("transactional_table_4"),
+        TRANSACTIONALTBL5("transactional_table_5"),
+        TRANSACTIONALTBL6("transactional_table_6"),
+        EXTERNALTABLE1("external_table_1"),
+        EXTERNALTABLE2("external_table_2"),
+        EXTERNALTABLE3("external_table_3"),
+        EXTERNALTABLE4("external_table_4"),
+        EXTERNALTABLE5("external_table_5"),
+        NONACIDPART("nonAcidPart"),
+        NONACIDNONBUCKET("nonAcidNonBucket");
+
+        private final String name;
+        @Override
+        public String toString() {
+            return name;
+        }
+        TableNames(String name) {
+            this.name = name;
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        hiveConf = new HiveConf(this.getClass());
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.CREATE_TABLES_AS_ACID, true);
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_CREATE_TABLES_AS_INSERT_ONLY, true);
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, true);
+        hiveConf.set(HiveConf.ConfVars.HIVEDEFAULTMANAGEDFILEFORMAT.varname, "ORC");
+        hiveConf.setVar(HiveConf.ConfVars.HIVE_TXN_MANAGER, DbTxnManager.class.getName());
+        hiveConf.set(HiveConf.ConfVars.METASTORE_CLIENT_CAPABILITIES.varname, "HIVEFULLACIDREAD,HIVEFULLACIDWRITE,HIVECACHEINVALIDATE,HIVEMANAGESTATS,HIVEMANAGEDINSERTWRITE,HIVEMANAGEDINSERTREAD");
+        TestTxnDbUtil.setConfValues(hiveConf);
+        TestTxnDbUtil.prepDb(hiveConf);
+
+        SessionState.start(new SessionState(hiveConf));
+        d = DriverFactory.newDriver(hiveConf);
+
+        conf = MetastoreConf.newMetastoreConf();
+        wh = new File(System.getProperty("java.io.tmpdir") + File.separator +
+                "hive" + File.separator + "warehouse" + File.separator + "hive" + File.separator);
+        wh.mkdirs();
+
+        ext_wh = new File(System.getProperty("java.io.tmpdir") + File.separator +
+                "hive" + File.separator + "warehouse" + File.separator + "hive-external" + File.separator);
+        ext_wh.mkdirs();
+
+        MetastoreConf.setVar(conf, ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS,
+                "org.apache.hadoop.hive.metastore.MetastoreDefaultTransformer");
+        MetastoreConf.setBoolVar(conf, ConfVars.HIVE_IN_TEST, false);
+        MetastoreConf.setVar(conf, ConfVars.WAREHOUSE, wh.getCanonicalPath());
+        MetastoreConf.setVar(conf, ConfVars.WAREHOUSE_EXTERNAL, ext_wh.getCanonicalPath());
+        MetastoreConf.setBoolVar(conf, MetastoreConf.ConfVars.CREATE_TABLES_AS_ACID, true);
+        client = new HiveMetaStoreClient(conf);
+
+
+        dropTables();
+        runStatementOnDriver("create database " + database_with_default_table_type +" with DBPROPERTIES('defaultTableType'='EXTERNAL')");
+        runStatementOnDriver("create database " + default_db);
+    }
+
+    /**
+     * this is to test differety types of Acid tables
+     */
+    String getTblProperties() {
+        return "TBLPROPERTIES ('transactional'='true')";
+    }
+
+    private void dropTables() throws Exception {
+        for(TableNames t : TableNames.values()) {
+            runStatementOnDriver("drop table if exists " + t);
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        try {
+            if (d != null) {
+                dropTables();
+                runStatementOnDriver("drop database if exists " + database_with_default_table_type +" cascade");
+                runStatementOnDriver("drop database if exists " + default_db + " cascade");
+                d.close();
+                d.destroy();
+                d = null;
+            }
+        } finally {
+            FileUtils.deleteDirectory(wh);
+            FileUtils.deleteDirectory(ext_wh);
+        }
+    }
+
+    /**
+     * Tests the TestDatabaseTableDefault.testCreateManagedTables method for creating managed tables in a special database.
+     * @throws Exception If there is an error creating managed tables
+     */
+    @Test
+    public void testCreateManagedTables() throws Exception {
+        runStatementOnDriver("use " + database_with_default_table_type);
+
+        runStatementOnDriver("create table " + TableNames.TRANSACTIONALTBL1 + " (id int, name string) " + getTblProperties());
+        Table managed_table_1 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL1.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_1.getTableType(), table_type_managed);
+
+        runStatementOnDriver("create managed table " + TableNames.TRANSACTIONALTBL2 + " (id int, name string) ");
+        Table managed_table_2 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL2.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_2.getTableType(), table_type_managed);
+
+        runStatementOnDriver("create transactional table " + TableNames.TRANSACTIONALTBL3 + " (id int, name string) ");
+        Table managed_table_3 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL3.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_3.getTableType(), table_type_managed);
+
+        runStatementOnDriver("create transactional table " + TableNames.TRANSACTIONALTBL4 + " like " + TableNames.TRANSACTIONALTBL3);
+        Table managed_table_4 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL4.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_4.getTableType(), table_type_managed);
+
+        runStatementOnDriver("create transactional table " + TableNames.TRANSACTIONALTBL5 + " as select * from " + TableNames.TRANSACTIONALTBL3);
+        Table managed_table_5 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL5.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_5.getTableType(), table_type_managed);
+
+        LOG.info("Test execution complete:testCreateManagedTables");
+    }
+
+
+    /**
+     * Tests the TestDatabaseTableDefault.testCreateExternalTables method for creating external tables in a special database.
+     * @throws Exception If there is an error creating external tables
+     */
+    @Test
+    public void testCreateExternalTables() throws Exception {

Review comment:
       so we know "create table" by default leads to external tables because of the translation layer in HMS. We should test to ensure that "create managed/transactional" in such databases will result in ACID tables.

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDatabaseTableDefault.java
##########
@@ -0,0 +1,304 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;

Review comment:
       seems unnecessary imports

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
##########
@@ -13600,7 +13616,12 @@ ASTNode analyzeCreateTable(
 
     // Handle different types of CREATE TABLE command
     // Note: each branch must call addDbAndTabToOutputs after finalizing table properties.
-
+    Database database  = getDatabase(qualifiedTabName.getDb());
+    boolean isDefaultTableTypeChanged = false;
+    if(database.getParameters() != null && database.getParameters().containsKey(DEFAULT_TABLE_TYPE) && database.getParameters().get(DEFAULT_TABLE_TYPE).equalsIgnoreCase("external")) {

Review comment:
       we should be able to compress the last 2 conditions using "getOrDefault()" call.

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDatabaseTableDefault.java
##########
@@ -0,0 +1,304 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.hive.common.FileUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.LockState;
+import org.apache.hadoop.hive.metastore.api.LockType;
+import org.apache.hadoop.hive.metastore.api.ShowCompactRequest;
+import org.apache.hadoop.hive.metastore.api.ShowCompactResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksRequest;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponseElement;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.metastore.utils.TestTxnDbUtil;
+import org.apache.hadoop.hive.metastore.txn.TxnStore;
+import org.apache.hadoop.hive.metastore.txn.TxnUtils;
+import org.apache.hadoop.hive.ql.exec.AbstractFileMergeOperator;
+import org.apache.hadoop.hive.ql.io.BucketCodec;
+import org.apache.hadoop.hive.ql.io.HiveInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.OrcFile;
+import org.apache.hadoop.hive.ql.io.orc.OrcInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.Reader;
+import org.apache.hadoop.hive.ql.lockmgr.TestDbTxnManager2;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.orc.OrcProto;
+import org.apache.tez.mapreduce.hadoop.MRJobConfig;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+//import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+/**
+ * This class resides in itests to facilitate running query using Tez engine, since the jars are
+ * fully loaded here, which is not the case if it stays in ql.
+ */
+public class TestDatabaseTableDefault {
+    static final private Logger LOG = LoggerFactory.getLogger(TestDatabaseTableDefault.class);
+
+    private HiveConf hiveConf;
+    private IDriver d;
+    private String database_with_default_table_type = "database_with_default_table_type";
+    private String default_db = "default_db";
+    private String table_type_managed = "MANAGED_TABLE";
+    private String table_type_external = "EXTERNAL_TABLE";
+    File ext_wh = null;
+    File wh = null;
+    protected static HiveMetaStoreClient client;
+    protected static Configuration conf;
+    private static enum TableNames {
+        TRANSACTIONALTBL1("transactional_table_1"),
+        TRANSACTIONALTBL2("transactional_table_2"),
+        TRANSACTIONALTBL3("transactional_table_3"),
+        TRANSACTIONALTBL4("transactional_table_4"),
+        TRANSACTIONALTBL5("transactional_table_5"),
+        TRANSACTIONALTBL6("transactional_table_6"),
+        EXTERNALTABLE1("external_table_1"),
+        EXTERNALTABLE2("external_table_2"),
+        EXTERNALTABLE3("external_table_3"),
+        EXTERNALTABLE4("external_table_4"),
+        EXTERNALTABLE5("external_table_5"),
+        NONACIDPART("nonAcidPart"),
+        NONACIDNONBUCKET("nonAcidNonBucket");
+
+        private final String name;
+        @Override
+        public String toString() {
+            return name;
+        }
+        TableNames(String name) {
+            this.name = name;
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        hiveConf = new HiveConf(this.getClass());
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.CREATE_TABLES_AS_ACID, true);
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_CREATE_TABLES_AS_INSERT_ONLY, true);
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, true);
+        hiveConf.set(HiveConf.ConfVars.HIVEDEFAULTMANAGEDFILEFORMAT.varname, "ORC");
+        hiveConf.setVar(HiveConf.ConfVars.HIVE_TXN_MANAGER, DbTxnManager.class.getName());
+        hiveConf.set(HiveConf.ConfVars.METASTORE_CLIENT_CAPABILITIES.varname, "HIVEFULLACIDREAD,HIVEFULLACIDWRITE,HIVECACHEINVALIDATE,HIVEMANAGESTATS,HIVEMANAGEDINSERTWRITE,HIVEMANAGEDINSERTREAD");
+        TestTxnDbUtil.setConfValues(hiveConf);
+        TestTxnDbUtil.prepDb(hiveConf);
+
+        SessionState.start(new SessionState(hiveConf));
+        d = DriverFactory.newDriver(hiveConf);
+
+        conf = MetastoreConf.newMetastoreConf();
+        wh = new File(System.getProperty("java.io.tmpdir") + File.separator +
+                "hive" + File.separator + "warehouse" + File.separator + "hive" + File.separator);
+        wh.mkdirs();
+
+        ext_wh = new File(System.getProperty("java.io.tmpdir") + File.separator +
+                "hive" + File.separator + "warehouse" + File.separator + "hive-external" + File.separator);
+        ext_wh.mkdirs();
+
+        MetastoreConf.setVar(conf, ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS,
+                "org.apache.hadoop.hive.metastore.MetastoreDefaultTransformer");
+        MetastoreConf.setBoolVar(conf, ConfVars.HIVE_IN_TEST, false);
+        MetastoreConf.setVar(conf, ConfVars.WAREHOUSE, wh.getCanonicalPath());
+        MetastoreConf.setVar(conf, ConfVars.WAREHOUSE_EXTERNAL, ext_wh.getCanonicalPath());
+        MetastoreConf.setBoolVar(conf, MetastoreConf.ConfVars.CREATE_TABLES_AS_ACID, true);
+        client = new HiveMetaStoreClient(conf);
+
+
+        dropTables();
+        runStatementOnDriver("create database " + database_with_default_table_type +" with DBPROPERTIES('defaultTableType'='EXTERNAL')");
+        runStatementOnDriver("create database " + default_db);
+    }
+
+    /**
+     * this is to test differety types of Acid tables
+     */
+    String getTblProperties() {
+        return "TBLPROPERTIES ('transactional'='true')";
+    }
+
+    private void dropTables() throws Exception {
+        for(TableNames t : TableNames.values()) {
+            runStatementOnDriver("drop table if exists " + t);
+        }
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        try {
+            if (d != null) {
+                dropTables();
+                runStatementOnDriver("drop database if exists " + database_with_default_table_type +" cascade");
+                runStatementOnDriver("drop database if exists " + default_db + " cascade");
+                d.close();
+                d.destroy();
+                d = null;
+            }
+        } finally {
+            FileUtils.deleteDirectory(wh);
+            FileUtils.deleteDirectory(ext_wh);
+        }
+    }
+
+    /**
+     * Tests the TestDatabaseTableDefault.testCreateManagedTables method for creating managed tables in a special database.
+     * @throws Exception If there is an error creating managed tables
+     */
+    @Test
+    public void testCreateManagedTables() throws Exception {
+        runStatementOnDriver("use " + database_with_default_table_type);
+
+        runStatementOnDriver("create table " + TableNames.TRANSACTIONALTBL1 + " (id int, name string) " + getTblProperties());
+        Table managed_table_1 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL1.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_1.getTableType(), table_type_managed);
+
+        runStatementOnDriver("create managed table " + TableNames.TRANSACTIONALTBL2 + " (id int, name string) ");
+        Table managed_table_2 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL2.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_2.getTableType(), table_type_managed);
+
+        runStatementOnDriver("create transactional table " + TableNames.TRANSACTIONALTBL3 + " (id int, name string) ");
+        Table managed_table_3 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL3.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_3.getTableType(), table_type_managed);
+
+        runStatementOnDriver("create transactional table " + TableNames.TRANSACTIONALTBL4 + " like " + TableNames.TRANSACTIONALTBL3);
+        Table managed_table_4 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL4.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_4.getTableType(), table_type_managed);
+
+        runStatementOnDriver("create transactional table " + TableNames.TRANSACTIONALTBL5 + " as select * from " + TableNames.TRANSACTIONALTBL3);
+        Table managed_table_5 = client.getTable(database_with_default_table_type, TableNames.TRANSACTIONALTBL5.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", managed_table_5.getTableType(), table_type_managed);
+
+        LOG.info("Test execution complete:testCreateManagedTables");
+    }
+
+
+    /**
+     * Tests the TestDatabaseTableDefault.testCreateExternalTables method for creating external tables in a special database.
+     * @throws Exception If there is an error creating external tables
+     */
+    @Test
+    public void testCreateExternalTables() throws Exception {
+        runStatementOnDriver("use " + database_with_default_table_type);
+
+        runStatementOnDriver("create table " + TableNames.EXTERNALTABLE1 + " (id int, name string)");
+        Table external_table_1 = client.getTable(database_with_default_table_type, TableNames.EXTERNALTABLE1.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", external_table_1.getTableType(), table_type_external);
+
+        runStatementOnDriver("create external table " + TableNames.EXTERNALTABLE2 + " (id int, name string) ");
+        Table external_table_2 = client.getTable(database_with_default_table_type, TableNames.EXTERNALTABLE2.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", external_table_2.getTableType(), table_type_external);
+
+        runStatementOnDriver("create table " + TableNames.EXTERNALTABLE3 + " like " + TableNames.EXTERNALTABLE2);
+        Table external_table_3 = client.getTable(database_with_default_table_type, TableNames.EXTERNALTABLE3.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", external_table_3.getTableType(), table_type_external);
+
+        runStatementOnDriver("create table " + TableNames.EXTERNALTABLE4 + " as select * from " + TableNames.EXTERNALTABLE2);
+        Table external_table_4 = client.getTable(database_with_default_table_type, TableNames.EXTERNALTABLE4.toString());
+        assertEquals("Created table type is expected to be managed but found to be external", external_table_4.getTableType(), table_type_external);
+
+        LOG.info("Test execution complete:testCreateExternalTables");
+    }
+

Review comment:
       Add a new test with a database that has defaultTableType=ACID and ensure that create table leads to ACID and create external table leads to external tables.

##########
File path: itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDatabaseTableDefault.java
##########
@@ -0,0 +1,304 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.FileUtil;
+import org.apache.hadoop.fs.LocatedFileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.RemoteIterator;
+import org.apache.hadoop.hive.common.FileUtils;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.LockState;
+import org.apache.hadoop.hive.metastore.api.LockType;
+import org.apache.hadoop.hive.metastore.api.ShowCompactRequest;
+import org.apache.hadoop.hive.metastore.api.ShowCompactResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksRequest;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponse;
+import org.apache.hadoop.hive.metastore.api.ShowLocksResponseElement;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
+import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars;
+import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
+import org.apache.hadoop.hive.metastore.utils.TestTxnDbUtil;
+import org.apache.hadoop.hive.metastore.txn.TxnStore;
+import org.apache.hadoop.hive.metastore.txn.TxnUtils;
+import org.apache.hadoop.hive.ql.exec.AbstractFileMergeOperator;
+import org.apache.hadoop.hive.ql.io.BucketCodec;
+import org.apache.hadoop.hive.ql.io.HiveInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.OrcFile;
+import org.apache.hadoop.hive.ql.io.orc.OrcInputFormat;
+import org.apache.hadoop.hive.ql.io.orc.Reader;
+import org.apache.hadoop.hive.ql.lockmgr.TestDbTxnManager2;
+import org.apache.hadoop.hive.ql.session.SessionState;
+import org.apache.orc.OrcProto;
+import org.apache.tez.mapreduce.hadoop.MRJobConfig;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+//import org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
+
+/**
+ * This class resides in itests to facilitate running query using Tez engine, since the jars are
+ * fully loaded here, which is not the case if it stays in ql.
+ */
+public class TestDatabaseTableDefault {
+    static final private Logger LOG = LoggerFactory.getLogger(TestDatabaseTableDefault.class);
+
+    private HiveConf hiveConf;
+    private IDriver d;
+    private String database_with_default_table_type = "database_with_default_table_type";
+    private String default_db = "default_db";
+    private String table_type_managed = "MANAGED_TABLE";
+    private String table_type_external = "EXTERNAL_TABLE";
+    File ext_wh = null;
+    File wh = null;
+    protected static HiveMetaStoreClient client;
+    protected static Configuration conf;
+    private static enum TableNames {
+        TRANSACTIONALTBL1("transactional_table_1"),
+        TRANSACTIONALTBL2("transactional_table_2"),
+        TRANSACTIONALTBL3("transactional_table_3"),
+        TRANSACTIONALTBL4("transactional_table_4"),
+        TRANSACTIONALTBL5("transactional_table_5"),
+        TRANSACTIONALTBL6("transactional_table_6"),
+        EXTERNALTABLE1("external_table_1"),
+        EXTERNALTABLE2("external_table_2"),
+        EXTERNALTABLE3("external_table_3"),
+        EXTERNALTABLE4("external_table_4"),
+        EXTERNALTABLE5("external_table_5"),
+        NONACIDPART("nonAcidPart"),
+        NONACIDNONBUCKET("nonAcidNonBucket");
+
+        private final String name;
+        @Override
+        public String toString() {
+            return name;
+        }
+        TableNames(String name) {
+            this.name = name;
+        }
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        hiveConf = new HiveConf(this.getClass());
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.CREATE_TABLES_AS_ACID, true);
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_CREATE_TABLES_AS_INSERT_ONLY, true);
+        HiveConf.setBoolVar(hiveConf, HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, true);
+        hiveConf.set(HiveConf.ConfVars.HIVEDEFAULTMANAGEDFILEFORMAT.varname, "ORC");
+        hiveConf.setVar(HiveConf.ConfVars.HIVE_TXN_MANAGER, DbTxnManager.class.getName());
+        hiveConf.set(HiveConf.ConfVars.METASTORE_CLIENT_CAPABILITIES.varname, "HIVEFULLACIDREAD,HIVEFULLACIDWRITE,HIVECACHEINVALIDATE,HIVEMANAGESTATS,HIVEMANAGEDINSERTWRITE,HIVEMANAGEDINSERTREAD");
+        TestTxnDbUtil.setConfValues(hiveConf);
+        TestTxnDbUtil.prepDb(hiveConf);
+
+        SessionState.start(new SessionState(hiveConf));
+        d = DriverFactory.newDriver(hiveConf);
+
+        conf = MetastoreConf.newMetastoreConf();
+        wh = new File(System.getProperty("java.io.tmpdir") + File.separator +
+                "hive" + File.separator + "warehouse" + File.separator + "hive" + File.separator);
+        wh.mkdirs();
+
+        ext_wh = new File(System.getProperty("java.io.tmpdir") + File.separator +
+                "hive" + File.separator + "warehouse" + File.separator + "hive-external" + File.separator);
+        ext_wh.mkdirs();
+
+        MetastoreConf.setVar(conf, ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS,
+                "org.apache.hadoop.hive.metastore.MetastoreDefaultTransformer");
+        MetastoreConf.setBoolVar(conf, ConfVars.HIVE_IN_TEST, false);
+        MetastoreConf.setVar(conf, ConfVars.WAREHOUSE, wh.getCanonicalPath());
+        MetastoreConf.setVar(conf, ConfVars.WAREHOUSE_EXTERNAL, ext_wh.getCanonicalPath());
+        MetastoreConf.setBoolVar(conf, MetastoreConf.ConfVars.CREATE_TABLES_AS_ACID, true);
+        client = new HiveMetaStoreClient(conf);
+
+
+        dropTables();
+        runStatementOnDriver("create database " + database_with_default_table_type +" with DBPROPERTIES('defaultTableType'='EXTERNAL')");
+        runStatementOnDriver("create database " + default_db);

Review comment:
       so defaultTableType can also be 'ACID' in which case, "create table" will result in ACID tables and only "create external table" should result in external tables.
   
   So the test should create another DB where it is set to ACID.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org