Search in sources :

Example 6 with BeamSqlTable

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

the class KafkaTableProviderTest method testBuildBeamSqlNestedBytesTable.

@Test
public void testBuildBeamSqlNestedBytesTable() {
    Table table = mockNestedBytesTable("hello");
    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) Test(org.junit.Test)

Example 7 with BeamSqlTable

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

the class MongoDbTableProviderTest method testBuildBeamSqlTable.

@Test
public void testBuildBeamSqlTable() {
    Table table = fakeTable("TEST", "mongodb://localhost:27017/database/collection");
    BeamSqlTable sqlTable = provider.buildBeamSqlTable(table);
    assertNotNull(sqlTable);
    assertTrue(sqlTable instanceof MongoDbTable);
    MongoDbTable mongoTable = (MongoDbTable) sqlTable;
    assertEquals("mongodb://localhost:27017", mongoTable.dbUri);
    assertEquals("database", mongoTable.dbName);
    assertEquals("collection", mongoTable.dbCollection);
}
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) Test(org.junit.Test)

Example 8 with BeamSqlTable

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

the class PubsubTableProviderTest method testCreatesTableWithJustTimestamp.

@Test
public void testCreatesTableWithJustTimestamp() {
    PubsubTableProvider provider = new PubsubTableProvider();
    Schema messageSchema = Schema.builder().addDateTimeField("event_timestamp").build();
    Table tableDefinition = tableDefinition().schema(messageSchema).build();
    BeamSqlTable pubsubTable = provider.buildBeamSqlTable(tableDefinition);
    assertNotNull(pubsubTable);
    assertEquals(messageSchema, pubsubTable.getSchema());
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Schema(org.apache.beam.sdk.schemas.Schema) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Example 9 with BeamSqlTable

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

the class PubsubTableProviderTest method testCreatesTable.

@Test
public void testCreatesTable() {
    PubsubTableProvider provider = new PubsubTableProvider();
    Schema messageSchema = Schema.builder().addDateTimeField("event_timestamp").addMapField("attributes", VARCHAR, VARCHAR).addRowField("payload", Schema.builder().build()).build();
    Table tableDefinition = tableDefinition().schema(messageSchema).build();
    BeamSqlTable pubsubTable = provider.buildBeamSqlTable(tableDefinition);
    assertNotNull(pubsubTable);
    assertEquals(messageSchema, pubsubTable.getSchema());
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Schema(org.apache.beam.sdk.schemas.Schema) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Example 10 with BeamSqlTable

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

the class PubsubLiteTableProviderTest method validSubscriptionTables.

@Test
public void validSubscriptionTables() {
    BeamSqlTable basic = makeTable(FULL_READ_SCHEMA, example(SubscriptionPath.class).toString(), ImmutableMap.of());
    assertTrue(basic instanceof PubsubLiteSubscriptionTable);
    BeamSqlTable row = makeTable(Schema.builder().addRowField(RowHandler.PAYLOAD_FIELD, Schema.builder().addStringField("abc").build()).build(), example(SubscriptionPath.class).toString(), ImmutableMap.of("format", "json"));
    assertTrue(row instanceof PubsubLiteSubscriptionTable);
    BeamSqlTable dlq = makeTable(Schema.builder().addRowField(RowHandler.PAYLOAD_FIELD, Schema.builder().addStringField("abc").build()).build(), example(SubscriptionPath.class).toString(), ImmutableMap.of("format", "json", "deadLetterQueue", "pubsub:projects/abc/topics/def"));
    assertTrue(dlq instanceof PubsubLiteSubscriptionTable);
}
Also used : BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Aggregations

BeamSqlTable (org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable)31 Test (org.junit.Test)25 Table (org.apache.beam.sdk.extensions.sql.meta.Table)21 Schema (org.apache.beam.sdk.schemas.Schema)5 BeamTableStatistics (org.apache.beam.sdk.extensions.sql.impl.BeamTableStatistics)3 DefaultTableFilter (org.apache.beam.sdk.extensions.sql.meta.DefaultTableFilter)2 Row (org.apache.beam.sdk.values.Row)2 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)2 JSONObject (com.alibaba.fastjson.JSONObject)1 TableFieldSchema (com.google.api.services.bigquery.model.TableFieldSchema)1 TableRow (com.google.api.services.bigquery.model.TableRow)1 TableSchema (com.google.api.services.bigquery.model.TableSchema)1 AutoService (com.google.auto.service.AutoService)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 PayloadMessages (org.apache.beam.sdk.extensions.protobuf.PayloadMessages)1 BeamSqlSeekableTable (org.apache.beam.sdk.extensions.sql.BeamSqlSeekableTable)1