Search in sources :

Example 36 with Table

use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.

the class TestTableProviderWithFilterPushDown method buildUp.

@Before
public void buildUp() {
    TestTableProvider tableProvider = new TestTableProvider();
    Table table = getTable("TEST", PushDownOptions.FILTER);
    tableProvider.createTable(table);
    tableProvider.addRows(table.getName(), row(BASIC_SCHEMA, 100, 1, "one", (short) 100, true), row(BASIC_SCHEMA, 200, 2, "two", (short) 200, false));
    sqlEnv = BeamSqlEnv.builder(tableProvider).setPipelineOptions(PipelineOptionsFactory.create()).setRuleSets(ImmutableList.of(RuleSets.ofList(rulesWithPushDown))).build();
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) Before(org.junit.Before)

Example 37 with Table

use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.

the class BigQueryTableProviderTest method testSelectWriteDispositionMethodAppend.

@Test
public void testSelectWriteDispositionMethodAppend() {
    Table table = fakeTableWithProperties("hello", "{ " + WRITE_DISPOSITION_PROPERTY + ": " + "\"" + WriteDisposition.WRITE_APPEND.toString() + "\" }");
    BigQueryTable sqlTable = (BigQueryTable) provider.buildBeamSqlTable(table);
    assertEquals(WriteDisposition.WRITE_APPEND, sqlTable.writeDisposition);
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Example 38 with Table

use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.

the class BigQueryTableProviderTest method testRuntimeExceptionThrown_whenAnInvalidPropertyIsSpecified.

@Test
public void testRuntimeExceptionThrown_whenAnInvalidPropertyIsSpecified() {
    Table table = fakeTableWithProperties("hello", "{ " + METHOD_PROPERTY + ": \"blahblah\" }");
    assertThrows(RuntimeException.class, () -> {
        provider.buildBeamSqlTable(table);
    });
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Example 39 with Table

use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.

the class BigQueryTableProviderTest method testRuntimeExceptionThrown_whenAPropertyOfInvalidTypeIsSpecified.

@Test
public void testRuntimeExceptionThrown_whenAPropertyOfInvalidTypeIsSpecified() {
    Table table = fakeTableWithProperties("hello", "{ " + METHOD_PROPERTY + ": 1337 }");
    assertThrows(RuntimeException.class, () -> {
        provider.buildBeamSqlTable(table);
    });
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Example 40 with Table

use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.

the class KafkaTableProviderTest method testBuildBeamSqlNestedThriftTable.

@Test
public void testBuildBeamSqlNestedThriftTable() {
    Table table = mockNestedThriftTable("hello", SimpleThriftMessage.class, TCompactProtocol.Factory.class);
    BeamSqlTable sqlTable = provider.buildBeamSqlTable(table);
    assertNotNull(sqlTable);
    assertTrue(sqlTable instanceof NestedPayloadKafkaTable);
    BeamKafkaTable kafkaTable = (BeamKafkaTable) sqlTable;
    assertEquals(LOCATION_BROKER, kafkaTable.getBootstrapServers());
    assertEquals(ImmutableList.of(LOCATION_TOPIC), kafkaTable.getTopics());
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) Test(org.junit.Test)

Aggregations

Table (org.apache.beam.sdk.extensions.sql.meta.Table)65 Test (org.junit.Test)49 BeamSqlTable (org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable)37 Schema (org.apache.beam.sdk.schemas.Schema)9 Before (org.junit.Before)9 InMemoryMetaStore (org.apache.beam.sdk.extensions.sql.meta.store.InMemoryMetaStore)8 TestTableProvider (org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider)7 TextTableProvider (org.apache.beam.sdk.extensions.sql.meta.provider.text.TextTableProvider)5 BeamTableStatistics (org.apache.beam.sdk.extensions.sql.impl.BeamTableStatistics)4 JSONObject (com.alibaba.fastjson.JSONObject)3 Row (org.apache.beam.sdk.values.Row)3 TableFieldSchema (com.google.api.services.bigquery.model.TableFieldSchema)2 TableRow (com.google.api.services.bigquery.model.TableRow)2 TableSchema (com.google.api.services.bigquery.model.TableSchema)2 Property (com.pholser.junit.quickcheck.Property)2 List (java.util.List)2 BeamSqlCli (org.apache.beam.sdk.extensions.sql.BeamSqlCli)2 InvalidTableException (org.apache.beam.sdk.extensions.sql.meta.provider.InvalidTableException)2 BigtableTableTestUtils.createReadTable (org.apache.beam.sdk.extensions.sql.meta.provider.bigtable.BigtableTableTestUtils.createReadTable)2 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)2