[
https://issues.apache.org/jira/browse/BEAM-7450?focusedWorklogId=256904&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-256904
]
ASF GitHub Bot logged work on BEAM-7450:
----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Jun/19 15:37
Start Date: 10/Jun/19 15:37
Worklog Time Spent: 10m
Work Description: iemejia commented on pull request #8718: [BEAM-7450]
Add an unbounded HcatalogIO reader using splittable pardo
URL: https://github.com/apache/beam/pull/8718#discussion_r292055480
##########
File path:
sdks/java/io/hcatalog/src/main/java/org/apache/beam/sdk/io/hcatalog/HCatalogIO.java
##########
@@ -123,8 +132,132 @@ public static Read read() {
return new
AutoValue_HCatalogIO_Read.Builder().setDatabase(DEFAULT_DATABASE).build();
}
+ /**
+ * Read unbounded data from Hive. This essentially means that as new
partitions show up, we start
+ * reading data for that partition.
+ */
+ public static UnboundedRead unbounded() {
+ return new UnboundedRead(
+ new AutoValue_HCatalogIO_Read.Builder()
+ .setDatabase(DEFAULT_DATABASE)
+ .setShouldTreatUnboundedAsBounded(TREAT_UNBOUNDED_AS_BOUNDED)
+ .build());
+ }
+
private HCatalogIO() {}
+ /** A {@link PTransform} to read unbounded data using HCatalog. */
+ public static final class UnboundedRead extends Read {
+
+ private Read readSpec;
+
+ private UnboundedRead(Read readSpec) {
+ this.readSpec = readSpec;
+ }
+
+ @Nullable
+ @Override
+ Map<String, String> getConfigProperties() {
+ return readSpec.getConfigProperties();
+ }
+
+ @Nullable
+ @Override
+ String getDatabase() {
+ return readSpec.getDatabase();
+ }
+
+ @Nullable
+ @Override
+ String getTable() {
+ return readSpec.getTable();
+ }
+
+ @Nullable
+ @Override
+ String getFilter() {
+ return readSpec.getFilter();
+ }
+
+ @Nullable
+ @Override
+ ReaderContext getContext() {
+ return readSpec.getContext();
+ }
+
+ @Nullable
+ @Override
+ Integer getSplitId() {
+ return readSpec.getSplitId();
+ }
+
+ @Override
+ Builder toBuilder() {
+ return readSpec.toBuilder();
+ }
+
+ @Nullable
+ @Override
+ Duration getPollingInterval() {
+ return readSpec.getPollingInterval();
+ }
+
+ @Nullable
+ @Override
+ SerializableComparator<Partition> getPartitionComparator() {
+ return readSpec.getPartitionComparator();
+ }
+
+ @Nullable
+ @Override
+ SerializableFunction<String, Instant> getWatermarkTimestampConverter() {
+ return readSpec.getWatermarkTimestampConverter();
+ }
+
+ @Nullable
+ @Override
+ ImmutableList<String> getPartitionCols() {
+ return readSpec.getPartitionCols();
+ }
+
+ @Nullable
+ @Override
+ String getWatermarkPartitionColumn() {
+ return readSpec.getWatermarkPartitionColumn();
+ }
+
+ @Nullable
+ @Override
+ Boolean getShouldTreatUnboundedAsBounded() {
+ return readSpec.getShouldTreatUnboundedAsBounded();
+ }
+
+ @Override
+ public PCollection<HCatRecord> expand(PBegin input) {
+ checkArgument(readSpec.getPollingInterval() != null,
"withPollingInterval() is required");
+ checkArgument(
+ readSpec.getWatermarkPartitionColumn() != null,
+ "withsWatermarkPartitionColumn() is required");
+ checkArgument(
+ readSpec.getWatermarkTimestampConverter() != null,
+ "withWatermarkTimestampConverter() is required");
+ checkArgument(readSpec.getPartitionCols() != null, "withPartitionCols()
is required");
+ checkArgument(
+ readSpec.getPartitionComparator() != null,
"withPartitionComparator() is required");
+ return input
+ .apply("ConvertToReadRequest", Create.of(new
ArrayList<>(Arrays.asList(readSpec))))
Review comment:
`.apply("ConvertToReadRequest", Create.of(readSpec))` simpler = better.
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 256904)
Time Spent: 3h (was: 2h 50m)
> Unbounded HCatalogIO Reader using splittable pardos
> ---------------------------------------------------
>
> Key: BEAM-7450
> URL: https://issues.apache.org/jira/browse/BEAM-7450
> Project: Beam
> Issue Type: New Feature
> Components: sdk-java-core
> Reporter: Ankit Jhalaria
> Assignee: Ankit Jhalaria
> Priority: Minor
> Time Spent: 3h
> Remaining Estimate: 0h
>
> # Current version of HcatalogIO is a bounded source.
> # While migrating our jobs to aws, we realized that it would be helpful to
> have an unbounded hcat reader that can behave as an unbounded source and
> polls for new partitions as and when they become available.
> # I have used splittable pardo(s) to do this. There is a flag that can be
> set to treat this as a bounded source which will terminate if that flag is
> set.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)