Search in sources :

Example 1 with JsonSchemaToTableSchema

use of org.apache.beam.sdk.io.gcp.bigquery.BigQueryHelpers.JsonSchemaToTableSchema in project beam by apache.

the class BigQueryIOTest method testRuntimeOptionsNotCalledInApplyOutput.

@Test
public void testRuntimeOptionsNotCalledInApplyOutput() {
    RuntimeTestOptions options = PipelineOptionsFactory.as(RuntimeTestOptions.class);
    BigQueryOptions bqOptions = options.as(BigQueryOptions.class);
    bqOptions.setTempLocation("gs://testbucket/testdir");
    Pipeline pipeline = TestPipeline.create(options);
    BigQueryIO.Write<TableRow> write = BigQueryIO.writeTableRows().to(options.getOutputTable()).withSchema(NestedValueProvider.of(options.getOutputSchema(), new JsonSchemaToTableSchema())).withoutValidation();
    pipeline.apply(Create.empty(TableRowJsonCoder.of())).apply(write);
    // Test that this doesn't throw.
    DisplayData.from(write);
}
Also used : TableRow(com.google.api.services.bigquery.model.TableRow) JsonSchemaToTableSchema(org.apache.beam.sdk.io.gcp.bigquery.BigQueryHelpers.JsonSchemaToTableSchema) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) Pipeline(org.apache.beam.sdk.Pipeline) Test(org.junit.Test)

Aggregations

TableRow (com.google.api.services.bigquery.model.TableRow)1 Pipeline (org.apache.beam.sdk.Pipeline)1 JsonSchemaToTableSchema (org.apache.beam.sdk.io.gcp.bigquery.BigQueryHelpers.JsonSchemaToTableSchema)1 TestPipeline (org.apache.beam.sdk.testing.TestPipeline)1 Test (org.junit.Test)1