use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigQueryTableProviderTest method testDefaultMethod_whenPropertiesAreNotSet.
@Test
public void testDefaultMethod_whenPropertiesAreNotSet() {
Table table = fakeTable("hello");
BigQueryTable sqlTable = (BigQueryTable) provider.buildBeamSqlTable(table);
assertEquals(Method.DIRECT_READ, sqlTable.method);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigQueryTableProviderTest method testSelectExportMethod.
@Test
public void testSelectExportMethod() {
Table table = fakeTableWithProperties("hello", "{ " + METHOD_PROPERTY + ": " + "\"" + Method.EXPORT.toString() + "\" }");
BigQueryTable sqlTable = (BigQueryTable) provider.buildBeamSqlTable(table);
assertEquals(Method.EXPORT, sqlTable.method);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigQueryTableProviderTest method testSelectWriteDispositionMethodEmpty.
@Test
public void testSelectWriteDispositionMethodEmpty() {
Table table = fakeTableWithProperties("hello", "{ " + WRITE_DISPOSITION_PROPERTY + ": " + "\"" + WriteDisposition.WRITE_EMPTY.toString() + "\" }");
BigQueryTable sqlTable = (BigQueryTable) provider.buildBeamSqlTable(table);
assertEquals(WriteDisposition.WRITE_EMPTY, sqlTable.writeDisposition);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigQueryTableProviderTest method testSelectDefaultMethodExplicitly.
@Test
public void testSelectDefaultMethodExplicitly() {
Table table = fakeTableWithProperties("hello", "{ " + METHOD_PROPERTY + ": " + "\"" + Method.DEFAULT.toString() + "\" }");
BigQueryTable sqlTable = (BigQueryTable) provider.buildBeamSqlTable(table);
assertEquals(Method.DEFAULT, sqlTable.method);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigQueryRowCountIT method testPipelineOptionInjection.
/**
* This tests if the pipeline options are injected in the path of SQL Transform.
*/
@Test
public void testPipelineOptionInjection() {
BigQueryTestTableProvider provider = new BigQueryTestTableProvider();
Table table = getTable("testTable", bigQuery.tableSpec());
provider.addTable("testTable", table);
pipeline.apply(Create.of(new TableRow().set("id", 1).set("name", "name1"), new TableRow().set("id", 2).set("name", "name2"), new TableRow().set("id", 3).set("name", "name3")).withCoder(TableRowJsonCoder.of())).apply(BigQueryIO.writeTableRows().to(bigQuery.tableSpec()).withSchema(new TableSchema().setFields(ImmutableList.of(new TableFieldSchema().setName("id").setType("INTEGER"), new TableFieldSchema().setName("name").setType("STRING")))).withoutValidation());
pipeline.run().waitUntilFinish();
// changing pipeline options
readingPipeline.getOptions().setJobName(FAKE_JOB_NAME);
// Reading from the table should update the statistics of bigQuery table
readingPipeline.apply(SqlTransform.query(" select * from testTable ").withDefaultTableProvider("bigquery", provider));
readingPipeline.run().waitUntilFinish();
BigQueryTestTable sqlTable = (BigQueryTestTable) provider.buildBeamSqlTable(table);
assertEquals(FAKE_JOB_NAME, sqlTable.getJobName());
}
Aggregations