Skip to content

Commit 25ed2f8

Browse files
committed
With max num of records
1 parent a226755 commit 25ed2f8

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

sdks/java/io/debezium/src/main/java/org/apache/beam/io/debezium/DebeziumReadSchemaTransformProvider.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ public PCollectionRowTuple expand(PCollectionRowTuple input) {
150150
readTransform
151151
.withMaxNumberOfRecords(testLimitRecords)
152152
.withMaxTimeToRun(testLimitMilliseconds);
153+
} else {
154+
if (configuration.getMaxNumberOfRecords() != null) {
155+
readTransform =
156+
readTransform.withMaxNumberOfRecords(
157+
configuration.getMaxNumberOfRecords());
158+
}
159+
160+
if (configuration.getMaxTimeToRun() != null) {
161+
readTransform =
162+
readTransform.withMaxTimeToRun(
163+
configuration.getMaxTimeToRun());
164+
}
153165
}
154166

155167
// TODO(pabloem): Database connection issues can be debugged here.
@@ -187,6 +199,14 @@ public PCollectionRowTuple expand(PCollectionRowTuple input) {
187199
@DefaultSchema(AutoValueSchema.class)
188200
@AutoValue
189201
public abstract static class DebeziumReadSchemaTransformConfiguration {
202+
@Nullable
203+
@SchemaFieldDescription("Maximum number of records to read before stopping.")
204+
public abstract Integer getMaxNumberOfRecords();
205+
206+
@Nullable
207+
@SchemaFieldDescription("Maximum time in milliseconds to run before stopping.")
208+
public abstract Long getMaxTimeToRun();
209+
190210
@SchemaFieldDescription("Username used to connect to the source database.")
191211
public abstract String getUsername();
192212

sdks/python/apache_beam/yaml/extended_tests/databases/debezium.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pipelines:
3131
host: "{DEBEZIUM_DB[HOST]}"
3232
port: "{DEBEZIUM_DB[PORT]}"
3333
table: "{DEBEZIUM_DB[TABLE]}"
34+
max_number_of_records: 2
35+
max_time_to_run: 600000
3436
connection_properties:
3537
- "database.dbname={DEBEZIUM_DB[DATABASE]}"
3638
- "plugin.name=pgoutput"

sdks/python/apache_beam/yaml/standard_io.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@
196196
port: 'port'
197197
table: 'table'
198198
connection_properties: 'debezium_connection_properties'
199+
max_number_of_records: 'max_number_of_records'
200+
max_time_to_run: 'max_time_to_run'
199201
underlying_provider:
200202
type: beamJar
201203
transforms:

0 commit comments

Comments
 (0)