Skip to content

Commit 6cd6c91

Browse files
committed
https://github.com/cloudera-labs/hms-mirror/issues/197
#196
1 parent 30f23f6 commit 6cd6c91

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
<groupId>com.cloudera.utils.hadoop</groupId>
3030
<artifactId>hms-mirror</artifactId>
31-
<version>2.3.1.6</version>
31+
<version>2.3.1.7</version>
3232
<packaging>jar</packaging>
3333

3434
<name>hms-mirror</name>

src/main/java/com/cloudera/utils/hms/mirror/datastrategy/DataStrategyBase.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public Boolean buildTableSchema(CopySpec copySpec) throws RequiredConfigurationE
249249
if (!TableUtils.isACID(source)) {
250250
// Non ACID tables.
251251
if (copySpec.isUpgrade() && TableUtils.isManaged(source)) {
252-
converted = TableUtils.makeExternal(target);
252+
converted = TableUtils.makeExternal(target, config);
253253
if (converted) {
254254
target.addIssue("Schema 'converted' from LEGACY managed to EXTERNAL");
255255
target.addProperty(HMS_MIRROR_LEGACY_MANAGED_FLAG, converted.toString());
@@ -264,7 +264,7 @@ public Boolean buildTableSchema(CopySpec copySpec) throws RequiredConfigurationE
264264
}
265265
} else {
266266
if (copySpec.isMakeExternal()) {
267-
converted = TableUtils.makeExternal(target);
267+
converted = TableUtils.makeExternal(target, config);
268268
}
269269
if (copySpec.isTakeOwnership()) {
270270
if (TableUtils.isACID(source)) {
@@ -281,12 +281,14 @@ public Boolean buildTableSchema(CopySpec copySpec) throws RequiredConfigurationE
281281
if (copySpec.isMakeNonTransactional()) {
282282
TableUtils.removeTblProperty(TRANSACTIONAL, target);
283283
TableUtils.removeTblProperty(TRANSACTIONAL_PROPERTIES, target);
284-
TableUtils.removeTblProperty(BUCKETING_VERSION, target);
284+
if (!config.getTransfer().getStorageMigration().isDistcp()) {
285+
TableUtils.removeTblProperty(BUCKETING_VERSION, target);
286+
}
285287
}
286288

287289
// We should also convert to external if we've enabled the conversion to Iceberg.
288290
if (copySpec.isMakeExternal() || config.getIcebergConversion().isEnable()) {
289-
converted = TableUtils.makeExternal(target);
291+
converted = TableUtils.makeExternal(target, config);
290292
}
291293

292294
if (copySpec.isTakeOwnership()) {
@@ -313,7 +315,7 @@ public Boolean buildTableSchema(CopySpec copySpec) throws RequiredConfigurationE
313315
}
314316

315317
if (config.getMigrateACID().isDowngrade() && copySpec.isMakeExternal()) {
316-
converted = TableUtils.makeExternal(target);
318+
converted = TableUtils.makeExternal(target, config);
317319
if (!config.isNoPurge()) {
318320
target.addProperty(EXTERNAL_TABLE_PURGE, Boolean.TRUE.toString());
319321
}
@@ -501,7 +503,9 @@ public Boolean buildTableSchema(CopySpec copySpec) throws RequiredConfigurationE
501503
// remove newer flags;
502504
TableUtils.removeTblProperty(EXTERNAL_TABLE_PURGE, target);
503505
TableUtils.removeTblProperty(DISCOVER_PARTITIONS, target);
504-
TableUtils.removeTblProperty(BUCKETING_VERSION, target);
506+
if (!config.getTransfer().getStorageMigration().isDistcp()) {
507+
TableUtils.removeTblProperty(BUCKETING_VERSION, target);
508+
}
505509
}
506510

507511
} else if (TableUtils.isView(target)) {

src/main/java/com/cloudera/utils/hms/mirror/service/DistCpService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void buildAllDistCpReports(ExecuteSession session, String outputDir) {
191191
String targetProtocol = NamespaceUtils.getProtocol(target);
192192

193193
if (nonNull(sourceProtocol) && nonNull(targetProtocol) && !sourceProtocol.equals(targetProtocol)) {
194-
distcpScriptSb.append("# Source and target protocols are different. This may cause issues with 'distcp' is -skipcrccheck isn't set.");
194+
distcpScriptSb.append("# Source and target protocols are different. This may cause issues with 'distcp' if -skipcrccheck isn't set.").append("\n");
195195
// Add -skipcrccheck to the distcp command
196196
distcpScriptSb.append("hadoop distcp ${DISTCP_OPTS} -skipcrccheck ").append(source).append(" ").append(target).append("\n").append("\n");
197197
} else {

src/main/java/com/cloudera/utils/hms/util/TableUtils.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.cloudera.utils.hms.mirror.MirrorConf;
2222
import com.cloudera.utils.hms.mirror.TablePropertyVars;
2323
import com.cloudera.utils.hms.mirror.domain.Cluster;
24+
import com.cloudera.utils.hms.mirror.domain.HmsMirrorConfig;
2425
import com.cloudera.utils.hms.mirror.domain.support.SerdeType;
2526
import com.cloudera.utils.hms.mirror.feature.IcebergState;
2627
import lombok.extern.slf4j.Slf4j;
@@ -551,7 +552,7 @@ public static Boolean prefixTableName(String tableName, String prefix, List<Stri
551552
return rtn;
552553
}
553554

554-
public static Boolean makeExternal(EnvironmentTable envTable) {
555+
public static Boolean makeExternal(EnvironmentTable envTable, HmsMirrorConfig config) {
555556
Boolean rtn = Boolean.FALSE;
556557
if (isManaged(envTable)) {
557558
log.debug("Converting table: {} to EXTERNAL", envTable.getName());
@@ -566,7 +567,9 @@ public static Boolean makeExternal(EnvironmentTable envTable) {
566567
// If ACID, remove transactional property to complete conversion to external.
567568
removeTblProperty(TablePropertyVars.TRANSACTIONAL, envTable.getDefinition());
568569
removeTblProperty(TablePropertyVars.TRANSACTIONAL_PROPERTIES, envTable.getDefinition());
569-
removeTblProperty(TablePropertyVars.BUCKETING_VERSION, envTable.getDefinition());
570+
if (!config.getTransfer().getStorageMigration().isDistcp()) {
571+
removeTblProperty(TablePropertyVars.BUCKETING_VERSION, envTable.getDefinition());
572+
}
570573
}
571574
return rtn;
572575
}

0 commit comments

Comments
 (0)