use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class MongoDbTableProviderTest method testBuildBeamSqlTable_withBadLocation_throwsException.
@Test
public void testBuildBeamSqlTable_withBadLocation_throwsException() {
ImmutableList<String> badLocations = ImmutableList.of("mongodb://localhost:27017/database/", "mongodb://localhost:27017/database", "localhost:27017/database/collection", "mongodb://:27017/database/collection", "mongodb://localhost:27017//collection", "mongodb://localhost/database/collection", "mongodb://localhost:/database/collection");
for (String badLocation : badLocations) {
Table table = fakeTable("TEST", badLocation);
assertThrows(IllegalArgumentException.class, () -> provider.buildBeamSqlTable(table));
}
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class MongoDbTableProviderTest method testBuildBeamSqlTable_withUsernameAndPassword.
@Test
public void testBuildBeamSqlTable_withUsernameAndPassword() {
Table table = fakeTable("TEST", "mongodb://username:pasword@localhost:27017/database/collection");
BeamSqlTable sqlTable = provider.buildBeamSqlTable(table);
assertNotNull(sqlTable);
assertTrue(sqlTable instanceof MongoDbTable);
MongoDbTable mongoTable = (MongoDbTable) sqlTable;
assertEquals("mongodb://username:pasword@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 MongoDbTableProviderTest method testBuildBeamSqlTable_withUsernameOnly.
@Test
public void testBuildBeamSqlTable_withUsernameOnly() {
Table table = fakeTable("TEST", "mongodb://username@localhost:27017/database/collection");
BeamSqlTable sqlTable = provider.buildBeamSqlTable(table);
assertNotNull(sqlTable);
assertTrue(sqlTable instanceof MongoDbTable);
MongoDbTable mongoTable = (MongoDbTable) sqlTable;
assertEquals("mongodb://username@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 testCreatesFlatTable.
@Test
public void testCreatesFlatTable() {
PubsubTableProvider provider = new PubsubTableProvider();
Schema messageSchema = Schema.builder().addDateTimeField("event_timestamp").addStringField("someField").build();
Table tableDefinition = tableDefinition().schema(messageSchema).build();
BeamSqlTable pubsubTable = provider.buildBeamSqlTable(tableDefinition);
assertNotNull(pubsubTable);
assertEquals(messageSchema, pubsubTable.getSchema());
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigQueryTableProviderTest method testSelectWriteDispositionMethodTruncate.
@Test
public void testSelectWriteDispositionMethodTruncate() {
Table table = fakeTableWithProperties("hello", "{ " + WRITE_DISPOSITION_PROPERTY + ": " + "\"" + WriteDisposition.WRITE_TRUNCATE.toString() + "\" }");
BigQueryTable sqlTable = (BigQueryTable) provider.buildBeamSqlTable(table);
assertEquals(WriteDisposition.WRITE_TRUNCATE, sqlTable.writeDisposition);
}
Aggregations