@Test public void testShouldReplacePartitionDisabledByConfig() throws IOException { Config config = ConfigFactory.parseMap(ImmutableMap.<String, String> of( HiveDatasetVersionCleaner.SHOULD_REPLACE_PARTITION_KEY, "false")); Assert.assertFalse(HiveDatasetVersionCleaner.shouldReplacePartition(config, replacedDb, replacedTable, Optional.of(replacementDb), Optional.of(replacementTable)), "Property governing partition replacement is set to false. " + "This should have been false. "); }
@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; }