ibzib commented on a change in pull request #16720:
URL: https://github.com/apache/beam/pull/16720#discussion_r810383072
##########
File path:
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIOStorageQueryTest.java
##########
@@ -753,6 +762,31 @@ public void testQuerySourceCreateReader() throws Exception
{
querySource.createReader(options);
}
+ @Test
+ public void testActuateProjectionPushdown() {
+ org.apache.beam.sdk.schemas.Schema schema =
+ org.apache.beam.sdk.schemas.Schema.builder()
+ .addStringField("foo")
+ .addStringField("bar")
+ .build();
+ TypedRead<Row> read =
+ BigQueryIO.read(
+ record ->
+ BigQueryUtils.toBeamRow(
+ record.getRecord(), schema,
ConversionOptions.builder().build()))
+ .withMethod(Method.DIRECT_READ)
+ .withCoder(SchemaCoder.of(schema));
+
+ assertTrue(read.supportsProjectionPushdown());
+ PTransform<PBegin, PCollection<Row>> pushdownT =
+ read.actuateProjectionPushdown(
+ ImmutableMap.of(new TupleTag<>("output"),
FieldAccessDescriptor.withFieldNames("foo")));
+
+ TypedRead<Row> pushdownRead = (TypedRead<Row>) pushdownT;
+ assertEquals(Method.DIRECT_READ, pushdownRead.getMethod());
+ assertThat(pushdownRead.getSelectedFields().get(),
Matchers.containsInAnyOrder("foo"));
+ }
Review comment:
e2e tests are easier after we add the optimizer to runners.
Added a unit test for supports=false.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]