Skip to content

Commit cfc1825

Browse files
committed
SQL Strategy only uses MSCK for partition discovery for Shadow Table: #145
1 parent 4f08f2e commit cfc1825

File tree

7 files changed

+32
-9
lines changed

7 files changed

+32
-9
lines changed

Writerside/images/cluster_tabs.png

-39.1 KB
Loading
-48.9 KB
Loading

Writerside/topics/Hive-Conversions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Modify the `hms-mirror` configuration to include the following settings:
2727
``` yaml
2828
clusters:
2929
LEFT|RIGHT:
30-
platformType: HDP2|HDP3|CHD5|CDH6|CDP7.1|CDP7_2|..
30+
platformType: HDP2|HDP3|CHD5|CDH6|CDP7.1|CDP7_2|...
3131
```
3232
</tab>
3333
</tabs>

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.2.0.12</version>
31+
<version>2.2.0.12.1</version>
3232
<packaging>jar</packaging>
3333

3434
<name>hms-mirror</name>

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,31 @@ public Boolean buildOutSql(TableMirror tableMirror) throws MissingDataPointExcep
225225
ret.addSql(TableUtils.CREATE_SHADOW_DESC, shadowCreateStmt);
226226
// Repair Partitions
227227
// TODO: Handle odd partitions.
228-
if (let.getPartitioned()) {
228+
if (config.loadMetadataDetails()) {
229+
// TODO: Write out the SQL to build the partitions. NOTE: We need to get the partition locations and modify them
230+
// to the new namespace.
231+
String tableParts = getTranslatorService().buildPartitionAddStatement(let);
232+
// This will be empty when there's no data and we need to handle that.
233+
if (!isBlank(tableParts)) {
234+
String addPartSql = MessageFormat.format(MirrorConf.ALTER_TABLE_PARTITION_ADD_LOCATION, set.getName(), tableParts);
235+
ret.addSql(MirrorConf.ALTER_TABLE_PARTITION_ADD_LOCATION_DESC, addPartSql);
236+
}
237+
} else {// if (config.getCluster(Environment.RIGHT).getPartitionDiscovery().isInitMSCK()) {
229238
String shadowMSCKStmt = MessageFormat.format(MirrorConf.MSCK_REPAIR_TABLE, set.getName());
230239
ret.addSql(TableUtils.REPAIR_DESC, shadowMSCKStmt);
240+
// String msckStmt = MessageFormat.format(MirrorConf.MSCK_REPAIR_TABLE, ret.getName());
241+
// // Add the MSCK repair to both initial and cleanup.
242+
// ret.addSql(TableUtils.REPAIR_DESC, msckStmt);
243+
// if (config.getTransfer().getStorageMigration().isDistcp()) {
244+
// ret.addCleanUpSql(TableUtils.REPAIR_DESC, msckStmt);
245+
// }
231246
}
247+
248+
249+
// if (let.getPartitioned()) {
250+
// String shadowMSCKStmt = MessageFormat.format(MirrorConf.MSCK_REPAIR_TABLE, set.getName());
251+
// ret.addSql(TableUtils.REPAIR_DESC, shadowMSCKStmt);
252+
// }
232253
}
233254
}
234255

src/main/java/com/cloudera/utils/hms/mirror/domain/HmsMirrorConfig.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,10 @@ public static boolean save(HmsMirrorConfig config, String configFilename, Boolea
292292
@JsonIgnore
293293
public Boolean loadMetadataDetails() {
294294
// When we're ALIGNED and asking fir DISTCP, we need to load the partition metadata.
295-
if (transfer.getStorageMigration().getTranslationType() == TranslationTypeEnum.ALIGNED
296-
&& getTransfer().getStorageMigration().isDistcp()) {
295+
if ((transfer.getStorageMigration().getTranslationType() == TranslationTypeEnum.ALIGNED
296+
&& getTransfer().getStorageMigration().isDistcp()) ||
297+
(dataStrategy == DataStrategyEnum.SQL
298+
&& getTransfer().getStorageMigration().getDataMovementStrategy() == DataMovementStrategyEnum.SQL)) {
297299
switch (dataStrategy) {
298300
case LINKED:
299301
case COMMON:

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,10 +1005,10 @@ public Boolean validate(ExecuteSession session, CliEnvironment cli) {
10051005
rtn.set(Boolean.FALSE);
10061006
}
10071007
}
1008-
if (!isBlank(config.getTransfer().getTargetNamespace())) {
1009-
runStatus.addError(SQL_DISTCP_ACID_W_STORAGE_OPTS);
1010-
rtn.set(Boolean.FALSE);
1011-
}
1008+
// if (!isBlank(config.getTransfer().getTargetNamespace())) {
1009+
// runStatus.addError(SQL_DISTCP_ACID_W_STORAGE_OPTS);
1010+
// rtn.set(Boolean.FALSE);
1011+
// }
10121012
}
10131013

10141014

0 commit comments

Comments
 (0)