Skip to content

Commit 237d3bb

Browse files
committed
helper method to construct BigQueryDynamicReadDescriptor
1 parent f84d473 commit 237d3bb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

examples/java/src/main/java/org/apache/beam/examples/cookbook/BigQueryStreamingTornadoes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ public static void applyBigQueryStreamingTornadoes(Pipeline p, Options options)
178178
MapElements.into(TypeDescriptor.of(BigQueryDynamicReadDescriptor.class))
179179
.via(
180180
(Instant t) ->
181-
BigQueryDynamicReadDescriptor.create(
182-
null, WEATHER_SAMPLES_TABLE, null, null, null, null)));
181+
BigQueryDynamicReadDescriptor.table(
182+
WEATHER_SAMPLES_TABLE, null, null)));
183183

184184
PCollection<TableRow> readDynamically =
185185
descriptors.apply("Read dynamically", BigQueryIO.readDynamicallyTableRows());

sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryDynamicReadDescriptor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,14 @@ public static BigQueryDynamicReadDescriptor create(
8888
return new AutoValue_BigQueryDynamicReadDescriptor(
8989
query, table, flattenResults, legacySql, selectedFields, rowRestriction);
9090
}
91+
92+
public static BigQueryDynamicReadDescriptor query(
93+
String query, Boolean flattenResults, Boolean legacySql) {
94+
return create(query, null, flattenResults, legacySql, null, null);
95+
}
96+
97+
public static BigQueryDynamicReadDescriptor table(
98+
String table, @Nullable List<String> selectedFields, @Nullable String rowRestriction) {
99+
return create(null, table, null, null, selectedFields, rowRestriction);
100+
}
91101
}

0 commit comments

Comments
 (0)