From e998ad693a970173dfb2f00882be2741fcdd6eae Mon Sep 17 00:00:00 2001 From: Naresh P R Date: Mon, 11 Nov 2019 20:05:29 +0530 Subject: [PATCH] HIVE-22478 - Import command fails from lower version to higher version when hive.strict.managed.tables enabled --- .../hadoop/hive/ql/parse/ImportSemanticAnalyzer.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java b/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java index ec75fa4e9a..40e3c8bff8 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/ImportSemanticAnalyzer.java @@ -282,17 +282,18 @@ public static boolean prepareImport(boolean isImportCmd, org.apache.hadoop.hive.metastore.api.Table tblObj = rv.getTable(); try { // The table can be non acid in case of replication from a cluster with STRICT_MANAGED set to false. - if (!TxnUtils.isTransactionalTable(tblObj) && replicationSpec.isInReplicationScope() && + if (!TxnUtils.isTransactionalTable(tblObj) && x.getConf().getBoolVar(HiveConf.ConfVars.HIVE_STRICT_MANAGED_TABLES) && (TableType.valueOf(tblObj.getTableType()) == TableType.MANAGED_TABLE)) { //TODO : dump metadata should be read to make sure that migration is required. upgradeTableDesc(tblObj, rv, x); //if the conversion is from non transactional to transactional table - if (TxnUtils.isTransactionalTable(tblObj)) { + if (TxnUtils.isTransactionalTable(tblObj) && replicationSpec.isInReplicationScope()) { replicationSpec.setMigratingToTxnTable(); } tblDesc = getBaseCreateTableDescFromTable(dbname, tblObj); - if (TableType.valueOf(tblObj.getTableType()) == TableType.EXTERNAL_TABLE) { + if (TableType.valueOf(tblObj.getTableType()) == TableType.EXTERNAL_TABLE && + replicationSpec.isInReplicationScope() ) { replicationSpec.setMigratingToExternalTable(); tblDesc.setExternal(true); // we should set this to null so default location for external tables is chosen on target -- 2.18.0