KumaravelKandasami commented on a change in pull request #2894: GOBBLIN-1054:
Refactor HiveSource to make partition filter extensible
URL: https://github.com/apache/incubator-gobblin/pull/2894#discussion_r383703426
##########
File path:
gobblin-data-management/src/main/java/org/apache/gobblin/data/management/copy/hive/filter/LookbackPartitionFilterGenerator.java
##########
@@ -41,34 +40,44 @@
* must be such that lexycographical string and date ordering are compatible.
* </p>
*/
+@Slf4j
public class LookbackPartitionFilterGenerator implements
PartitionFilterGenerator {
public static final String PARTITION_COLUMN =
HiveDatasetFinder.HIVE_DATASET_PREFIX + ".partition.filter.datetime.column";
public static final String LOOKBACK = HiveDatasetFinder.HIVE_DATASET_PREFIX
+ ".partition.filter.datetime.lookback";
public static final String DATETIME_FORMAT =
HiveDatasetFinder.HIVE_DATASET_PREFIX + ".partition.filter.datetime.format";
- private static final String ERROR_MESSAGE =
LookbackPartitionFilterGenerator.class.getName()
- + " requires the following properties " + Arrays.toString(new
String[]{PARTITION_COLUMN, LOOKBACK, DATETIME_FORMAT});
-
- private final String partitionColumn;
- private final Period lookback;
- private final DateTimeFormatter formatter;
+ private final Properties prop;
public LookbackPartitionFilterGenerator(Properties properties) {
- Preconditions.checkArgument(properties.containsKey(PARTITION_COLUMN),
ERROR_MESSAGE);
- Preconditions.checkArgument(properties.containsKey(LOOKBACK),
ERROR_MESSAGE);
- Preconditions.checkArgument(properties.containsKey(DATETIME_FORMAT),
ERROR_MESSAGE);
-
- this.partitionColumn = properties.getProperty(PARTITION_COLUMN);
- this.lookback = Period.parse(properties.getProperty(LOOKBACK));
- this.formatter =
DateTimeFormat.forPattern(properties.getProperty(DATETIME_FORMAT));
+ this.prop = (properties == null) ? System.getProperties(): properties;
}
@Override
public String getFilter(HiveDataset hiveDataset) {
- DateTime limitDate = (new DateTime()).minus(this.lookback);
+ if (isValidConfig()) {
Review comment:
I do agree with you on keeping the code backward compatible, however, the
prior implementation of the `HiveSource.java `checks whether the expected
properties for `LookbackPartitionFilterGenerator` exists before instantiating
the `LookbackPartitionFilterGenerator`, so the `IllegalArgumentException` is
never raised during runtime. Also, the prior implementation of the
`HiveSource.java `support no PartitionFilter case. To support these existing
behavior, we cannot throw exception when the validation fails.
Reference to prior implementation of `HiveSource.java`:
https://github.com/apache/incubator-gobblin/pull/2894/commits/dca6e665020b147c4009f0f23511c228c64415b6#diff-071355ec76a4f7e8167359040ff492f0L306-L313
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services