Class TestBigQuery
- java.lang.Object
-
- org.apache.beam.sdk.io.gcp.bigquery.TestBigQuery
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class TestBigQuery extends java.lang.Object implements org.junit.rules.TestRule
Test rule which creates a new table with specified schema, with randomized name and exposes few APIs to work with it.Deletes the table on test shutdown.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TestBigQuery.PollingAssertion
Interface to implement a polling assertion.class
TestBigQuery.RowsAssertion
Interface for creating a polling eventual assertion.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.junit.runners.model.Statement
apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
TestBigQuery.RowsAssertion
assertThatAllRows(org.apache.beam.sdk.schemas.Schema rowSchema)
static TestBigQuery
create(org.apache.beam.sdk.schemas.Schema tableSchema)
Creates an instance of this rule.java.util.List<org.apache.beam.sdk.values.Row>
getFlatJsonRows(org.apache.beam.sdk.schemas.Schema rowSchema)
Loads rows from BigQuery intoRows
with givenSchema
.com.google.api.services.bigquery.model.TableDataInsertAllResponse
insertRows(org.apache.beam.sdk.schemas.Schema rowSchema, org.apache.beam.sdk.values.Row... rows)
com.google.api.services.bigquery.model.TableReference
tableReference()
java.lang.String
tableSpec()
-
-
-
Method Detail
-
create
@Experimental(SCHEMAS) public static TestBigQuery create(org.apache.beam.sdk.schemas.Schema tableSchema)
Creates an instance of this rule.Loads GCP configuration from
TestPipelineOptions
.
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
- Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
tableSpec
@RequiresNonNull("table") public java.lang.String tableSpec()
-
tableReference
@RequiresNonNull("table") public com.google.api.services.bigquery.model.TableReference tableReference()
-
insertRows
@Experimental(SCHEMAS) @RequiresNonNull("table") public com.google.api.services.bigquery.model.TableDataInsertAllResponse insertRows(org.apache.beam.sdk.schemas.Schema rowSchema, org.apache.beam.sdk.values.Row... rows) throws java.io.IOException
- Throws:
java.io.IOException
-
getFlatJsonRows
@Experimental(SCHEMAS) public java.util.List<org.apache.beam.sdk.values.Row> getFlatJsonRows(org.apache.beam.sdk.schemas.Schema rowSchema)
Loads rows from BigQuery intoRows
with givenSchema
.Current implementation only supports flat
Rows
and targetSchemas
withSchema.FieldType.STRING
fields only.
-
assertThatAllRows
@Experimental(SCHEMAS) public TestBigQuery.RowsAssertion assertThatAllRows(org.apache.beam.sdk.schemas.Schema rowSchema)
-
-