diff --git a/ql/src/java/org/apache/hadoop/hive/ql/util/HiveStrictManagedMigration.java b/ql/src/java/org/apache/hadoop/hive/ql/util/HiveStrictManagedMigration.java index 5e658a67976aa6f081c5373286685156d3642a1c..2c1ba5fc480a29d9ab8964bed075eb33ebf5dcc0 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/util/HiveStrictManagedMigration.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/util/HiveStrictManagedMigration.java @@ -77,6 +77,7 @@ import static java.util.stream.Collectors.toList; import static org.apache.hadoop.hive.metastore.TableType.EXTERNAL_TABLE; import static org.apache.hadoop.hive.metastore.TableType.MANAGED_TABLE; +import static org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_STORAGE; public class HiveStrictManagedMigration { @@ -1004,6 +1005,8 @@ public static TableMigrationOption determineMigrationTypeAutomatically(Table tab private static final Map convertToExternalTableProps = new HashMap<>(); private static final Map convertToAcidTableProps = new HashMap<>(); private static final Map convertToMMTableProps = new HashMap<>(); + private static final String KUDU_LEGACY_STORAGE_HANDLER = "com.cloudera.kudu.hive.KuduStorageHandler"; + private static final String KUDU_STORAGE_HANDLER = "org.apache.hadoop.hive.kudu.KuduStorageHandler"; static { convertToExternalTableProps.put("EXTERNAL", "TRUE"); @@ -1369,7 +1372,9 @@ void updatePartitionLocation(String dbName, Table table, String partName, alterPartitionInternal(table, modifiedPart); } - void updateTableProperties(Table table, Map props) throws HiveException { + void updateTableProperties(Table table, Map propsToApply) throws HiveException { + Map props = new HashMap<>(propsToApply); + migrateKuduStorageHandlerType(table, props); StringBuilder sb = new StringBuilder(); boolean isTxn = TxnUtils.isTransactionalTable(table); org.apache.hadoop.hive.ql.metadata.Table modifiedTable = doFileRename ? @@ -1636,6 +1641,22 @@ static boolean hasEquivalentErasureCodingPolicy(HadoopShims.HdfsErasureCodingShi } } + /** + * While upgrading from earlier versions we need to amend storage_handler value for Kudu tables that might + * have the legacy value set. + * @param table + * @param props + */ + private static void migrateKuduStorageHandlerType(Table table, Map props) { + Map tableProperties = table.getParameters(); + if (tableProperties != null) { + String storageHandler = tableProperties.get(META_TABLE_STORAGE); + if (KUDU_LEGACY_STORAGE_HANDLER.equals(storageHandler)) { + props.put(META_TABLE_STORAGE, KUDU_STORAGE_HANDLER); + } + } + } + /** * can set it from tests to test when config needs something other than default values. */