@@ -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 )) {
0 commit comments