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.TestRuleTest 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 interfaceTestBigQuery.PollingAssertionInterface to implement a polling assertion.classTestBigQuery.RowsAssertionInterface 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.Statementapply(org.junit.runners.model.Statement base, org.junit.runner.Description description)TestBigQuery.RowsAssertionassertThatAllRows(org.apache.beam.sdk.schemas.Schema rowSchema)static TestBigQuerycreate(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 intoRowswith givenSchema.com.google.api.services.bigquery.model.TableDataInsertAllResponseinsertRows(org.apache.beam.sdk.schemas.Schema rowSchema, org.apache.beam.sdk.values.Row... rows)com.google.api.services.bigquery.model.TableReferencetableReference()java.lang.StringtableSpec()
-
-
-
Method Detail
-
create
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:
applyin 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
@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
public java.util.List<org.apache.beam.sdk.values.Row> getFlatJsonRows(org.apache.beam.sdk.schemas.Schema rowSchema)
Loads rows from BigQuery intoRowswith givenSchema.Current implementation only supports flat
Rowsand targetSchemaswithSchema.FieldType.STRINGfields only.
-
assertThatAllRows
public TestBigQuery.RowsAssertion assertThatAllRows(org.apache.beam.sdk.schemas.Schema rowSchema)
-
-