use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class KafkaTableProviderTest method testBuildBeamSqlAvroTable.
@Test
public void testBuildBeamSqlAvroTable() {
Table table = mockTable("hello", "avro");
BeamSqlTable sqlTable = provider.buildBeamSqlTable(table);
assertNotNull(sqlTable);
assertTrue(sqlTable instanceof BeamKafkaTable);
BeamKafkaTable kafkaTable = (BeamKafkaTable) sqlTable;
assertEquals(LOCATION_BROKER, kafkaTable.getBootstrapServers());
assertEquals(ImmutableList.of(LOCATION_TOPIC), kafkaTable.getTopics());
}
use of org.apache.beam.sdk.extensions.sql.meta.Table 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());
}
use of org.apache.beam.sdk.extensions.sql.meta.Table 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);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class PubsubTableProviderTest method testThrowsIfTimestampFieldNotProvided.
@Test
public void testThrowsIfTimestampFieldNotProvided() {
PubsubTableProvider provider = new PubsubTableProvider();
Schema messageSchema = Schema.builder().addMapField("attributes", VARCHAR, VARCHAR).addRowField("payload", Schema.builder().build()).build();
Table tableDefinition = tableDefinition().schema(messageSchema).build();
thrown.expectMessage("Unsupported");
thrown.expectMessage("'event_timestamp'");
provider.buildBeamSqlTable(tableDefinition);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table 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());
}
Aggregations