Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.6k
[BEAM-117] Validate display data registration in Dataflow Runner#325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.beam.runners.dataflow.io; | ||
| import static org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasDisplayItem; | ||
| import static org.hamcrest.Matchers.hasItem; | ||
| import static org.junit.Assert.assertThat; | ||
| import org.apache.beam.runners.dataflow.DataflowPipelineRunner; | ||
| import org.apache.beam.runners.dataflow.transforms.DataflowDisplayDataEvaluator; | ||
| import org.apache.beam.sdk.io.AvroIO; | ||
| import org.apache.beam.sdk.transforms.display.DisplayData; | ||
| import org.apache.beam.sdk.transforms.display.DisplayDataEvaluator; | ||
| import org.apache.avro.Schema; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.JUnit4; | ||
| import java.util.Set; | ||
| /** | ||
| * {@link DataflowPipelineRunner} specific tests for {@link AvroIO} transforms. | ||
| */ | ||
| @RunWith(JUnit4.class) | ||
| public class DataflowAvroIOTest { | ||
| @Test | ||
| public void testPrimitiveWriteDisplayData() { | ||
| DisplayDataEvaluator evaluator = DataflowDisplayDataEvaluator.create(); | ||
| AvroIO.Write.Bound<?> write = AvroIO.Write | ||
| .to("foo") | ||
| .withSchema(Schema.create(Schema.Type.STRING)) | ||
| .withoutValidation(); | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(write); | ||
| assertThat("AvroIO.Write should include the file pattern in its primitive transform", | ||
| displayData, hasItem(hasDisplayItem("fileNamePattern"))); | ||
| } | ||
| @Test | ||
| public void testPrimitiveReadDisplayData() { | ||
| DisplayDataEvaluator evaluator = DataflowDisplayDataEvaluator.create(); | ||
| AvroIO.Read.Bound<?> read = AvroIO.Read.from("foo.*") | ||
| .withSchema(Schema.create(Schema.Type.STRING)) | ||
| .withoutValidation(); | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(read); | ||
| assertThat("AvroIO.Read should include the file pattern in its primitive transform", | ||
| displayData, hasItem(hasDisplayItem("filePattern"))); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -18,7 +18,6 @@ | ||
| package org.apache.beam.runners.dataflow.io; | ||
| import static org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasDisplayItem; | ||
| import static org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasKey; | ||
| import static org.hamcrest.Matchers.hasItem; | ||
| import static org.junit.Assert.assertThat; | ||
| @@ -39,6 +38,30 @@ | ||
| * Unit tests for Dataflow usage of {@link BigQueryIO} transforms. | ||
| */ | ||
| public class DataflowBigQueryIOTest { | ||
| @Test | ||
| public void testTableSourcePrimitiveDisplayData() { | ||
| DisplayDataEvaluator evaluator = DataflowDisplayDataEvaluator.create(); | ||
| BigQueryIO.Read.Bound read = BigQueryIO.Read | ||
| .from("project:dataset.tableId") | ||
| .withoutValidation(); | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(read); | ||
| assertThat("BigQueryIO.Read should include the table spec in its primitive display data", | ||
| displayData, hasItem(hasDisplayItem("table"))); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion reads unfortunately -- | ||
| } | ||
| @Test | ||
| public void testQuerySourcePrimitiveDisplayData() { | ||
| DisplayDataEvaluator evaluator = DataflowDisplayDataEvaluator.create(); | ||
| BigQueryIO.Read.Bound read = BigQueryIO.Read | ||
| .fromQuery("foobar") | ||
| .withoutValidation(); | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(read); | ||
| assertThat("BigQueryIO.Read should include the query in its primitive display data", | ||
| displayData, hasItem(hasDisplayItem("query"))); | ||
| } | ||
| @Test | ||
| public void testBatchSinkPrimitiveDisplayData() { | ||
| DataflowPipelineOptions options = DataflowDisplayDataEvaluator.getDefaultOptions(); | ||
| @@ -63,9 +86,9 @@ private void testSinkPrimitiveDisplayData(DataflowPipelineOptions options) { | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(write); | ||
| assertThat("BigQueryIO.Write should include the table spec in its primitive display data", | ||
| displayData, hasItem(hasDisplayItem(hasKey("tableSpec")))); | ||
| displayData, hasItem(hasDisplayItem("tableSpec"))); | ||
| assertThat("BigQueryIO.Write should include the table schema in its primitive display data", | ||
| displayData, hasItem(hasDisplayItem(hasKey("schema")))); | ||
| displayData, hasItem(hasDisplayItem("schema"))); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.beam.runners.dataflow.io; | ||
| import static org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasDisplayItem; | ||
| import static org.hamcrest.Matchers.hasItem; | ||
| import static org.junit.Assert.assertThat; | ||
| import org.apache.beam.runners.dataflow.transforms.DataflowDisplayDataEvaluator; | ||
| import org.apache.beam.sdk.io.DatastoreIO; | ||
| import org.apache.beam.sdk.transforms.PTransform; | ||
| import org.apache.beam.sdk.transforms.display.DisplayData; | ||
| import org.apache.beam.sdk.transforms.display.DisplayDataEvaluator; | ||
| import org.apache.beam.sdk.values.PCollection; | ||
| import org.apache.beam.sdk.values.PInput; | ||
| import com.google.api.services.datastore.DatastoreV1; | ||
| import org.junit.Test; | ||
| import java.util.Set; | ||
| /** | ||
| * Unit tests for Dataflow usage of {@link DatastoreIO} transforms. | ||
| */ | ||
| public class DataflowDatastoreIOTest { | ||
| @Test | ||
| public void testSourcePrimitiveDisplayData() { | ||
| DisplayDataEvaluator evaluator = DataflowDisplayDataEvaluator.create(); | ||
| PTransform<PInput, ?> read = DatastoreIO.readFrom( | ||
| "myDataset", DatastoreV1.Query.newBuilder().build()); | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(read); | ||
| assertThat("DatastoreIO read should include the dataset in its primitive display data", | ||
| displayData, hasItem(hasDisplayItem("dataset"))); | ||
| } | ||
| @Test | ||
| public void testSinkPrimitiveDisplayData() { | ||
| DisplayDataEvaluator evaluator = DataflowDisplayDataEvaluator.create(); | ||
| PTransform<PCollection<DatastoreV1.Entity>, ?> write = DatastoreIO.writeTo("myDataset"); | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(write); | ||
| assertThat("DatastoreIO write should include the dataset in its primitive display data", | ||
| displayData, hasItem(hasDisplayItem("dataset"))); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.beam.runners.dataflow.io; | ||
| import static org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasDisplayItem; | ||
| import static org.hamcrest.Matchers.hasItem; | ||
| import static org.junit.Assert.assertThat; | ||
| import org.apache.beam.runners.dataflow.DataflowPipelineRunner; | ||
| import org.apache.beam.runners.dataflow.transforms.DataflowDisplayDataEvaluator; | ||
| import org.apache.beam.sdk.io.PubsubIO; | ||
| import org.apache.beam.sdk.transforms.display.DisplayData; | ||
| import org.apache.beam.sdk.transforms.display.DisplayDataEvaluator; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.JUnit4; | ||
| import java.util.Set; | ||
| /** | ||
| * {@link DataflowPipelineRunner} specific tests for {@link PubsubIO} transforms. | ||
| */ | ||
| @RunWith(JUnit4.class) | ||
| public class DataflowPubsubIOTest { | ||
| @Test | ||
| public void testPrimitiveWriteDisplayData() { | ||
| DisplayDataEvaluator evaluator = DataflowDisplayDataEvaluator.create(); | ||
| PubsubIO.Write.Bound<?> write = PubsubIO.Write | ||
| .topic("projects/project/topics/topic"); | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(write); | ||
| assertThat("PubsubIO.Write should include the topic in its primitive display data", | ||
| displayData, hasItem(hasDisplayItem("topic"))); | ||
| } | ||
| @Test | ||
| public void testPrimitiveReadDisplayData() { | ||
| DisplayDataEvaluator evaluator = DataflowDisplayDataEvaluator.create(); | ||
| PubsubIO.Read.Bound<String> read = PubsubIO.Read.topic("projects/project/topics/topic"); | ||
| Set<DisplayData> displayData = evaluator.displayDataForPrimitiveTransforms(read); | ||
| assertThat("PubsubIO.Read should include the topic in its primitive display data", | ||
| displayData, hasItem(hasDisplayItem("topic"))); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this validation required adding dependencies on avro and datastore. Is there a reason these dependencies appeared now but not before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously there was no direct dependency on Avro/Datastore in Dataflow runner. This change adds integration tests which directly reference classes in these packages.