@Test public void testShouldReplacePartitionHappyPath() throws IOException { Assert.assertTrue(HiveDatasetVersionCleaner.shouldReplacePartition(config, replacedDb, replacedTable, Optional.of(replacementDb), Optional.of(replacementTable)), "Replaced and replacement db / table are different. " + "This should have been true. "); Assert.assertTrue(HiveDatasetVersionCleaner.shouldReplacePartition(config, replacedDb, replacedTable, Optional.of(replacementDb), Optional.of(replacedTable)), "Replaced and replacement db / table are different. " + "This should have been true. "); Assert.assertTrue(HiveDatasetVersionCleaner.shouldReplacePartition(config, replacedDb, replacedTable, Optional.of(replacedDb), Optional.of(replacementTable)), "Replaced and replacement db / table are different. " + "This should have been true. "); }
@VisibleForTesting protected static boolean shouldReplacePartition(Config config, String replacedPartitionDbName, String replacedPartitionTableName, Optional<String> replacementPartitionDbName, Optional<String> replacementPartitionTableName) { boolean shouldReplacePartition = ConfigUtils.getBoolean(config, SHOULD_REPLACE_PARTITION_KEY, false); if (!replacementPartitionDbName.isPresent() || !replacementPartitionTableName.isPresent()) { return false; } else { return shouldReplacePartition && !(replacedPartitionDbName.equalsIgnoreCase(replacementPartitionDbName.get()) && replacedPartitionTableName.equalsIgnoreCase(replacementPartitionTableName.get())); } }
HiveDatasetVersionCleaner extends VersionCleaner { @VisibleForTesting protected static boolean shouldReplacePartition(Config config, String replacedPartitionDbName, String replacedPartitionTableName, Optional<String> replacementPartitionDbName, Optional<String> replacementPartitionTableName) { boolean shouldReplacePartition = ConfigUtils.getBoolean(config, SHOULD_REPLACE_PARTITION_KEY, false); if (!replacementPartitionDbName.isPresent() || !replacementPartitionTableName.isPresent()) { return false; } else { return shouldReplacePartition && !(replacedPartitionDbName.equalsIgnoreCase(replacementPartitionDbName.get()) && replacedPartitionTableName.equalsIgnoreCase(replacementPartitionTableName.get())); } } }
HiveDatasetVersionCleaner extends VersionCleaner { @VisibleForTesting protected static boolean shouldReplacePartition(Config config, String replacedPartitionDbName, String replacedPartitionTableName, Optional<String> replacementPartitionDbName, Optional<String> replacementPartitionTableName) { boolean shouldReplacePartition = ConfigUtils.getBoolean(config, SHOULD_REPLACE_PARTITION_KEY, false); if (!replacementPartitionDbName.isPresent() || !replacementPartitionTableName.isPresent()) { return false; } else { return shouldReplacePartition && !(replacedPartitionDbName.equalsIgnoreCase(replacementPartitionDbName.get()) && replacedPartitionTableName.equalsIgnoreCase(replacementPartitionTableName.get())); } } HiveDatasetVersionCleaner(DatasetVersion datasetVersion, CleanableDataset cleanableDataset); }
HiveDatasetVersionCleaner extends VersionCleaner { @VisibleForTesting protected static boolean shouldReplacePartition(Config config, String replacedPartitionDbName, String replacedPartitionTableName, Optional<String> replacementPartitionDbName, Optional<String> replacementPartitionTableName) { boolean shouldReplacePartition = ConfigUtils.getBoolean(config, SHOULD_REPLACE_PARTITION_KEY, false); if (!replacementPartitionDbName.isPresent() || !replacementPartitionTableName.isPresent()) { return false; } else { return shouldReplacePartition && !(replacedPartitionDbName.equalsIgnoreCase(replacementPartitionDbName.get()) && replacedPartitionTableName.equalsIgnoreCase(replacementPartitionTableName.get())); } } HiveDatasetVersionCleaner(DatasetVersion datasetVersion, CleanableDataset cleanableDataset); @Override void preCleanAction(); @Override void clean(); @Override void postCleanAction(); }
HiveDatasetVersionCleaner extends VersionCleaner { @VisibleForTesting protected static boolean shouldReplacePartition(Config config, String replacedPartitionDbName, String replacedPartitionTableName, Optional<String> replacementPartitionDbName, Optional<String> replacementPartitionTableName) { boolean shouldReplacePartition = ConfigUtils.getBoolean(config, SHOULD_REPLACE_PARTITION_KEY, false); if (!replacementPartitionDbName.isPresent() || !replacementPartitionTableName.isPresent()) { return false; } else { return shouldReplacePartition && !(replacedPartitionDbName.equalsIgnoreCase(replacementPartitionDbName.get()) && replacedPartitionTableName.equalsIgnoreCase(replacementPartitionTableName.get())); } } HiveDatasetVersionCleaner(DatasetVersion datasetVersion, CleanableDataset cleanableDataset); @Override void preCleanAction(); @Override void clean(); @Override void postCleanAction(); static final String REPLACEMENT_HIVE_DB_NAME_KEY; static final String REPLACEMENT_HIVE_TABLE_NAME_KEY; static final String SHOULD_REPLACE_PARTITION_KEY; }