use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigtableTableCreationFailuresTest method testCreateWithoutLocationFails.
@Test
public void testCreateWithoutLocationFails() {
String createTable = "CREATE EXTERNAL TABLE fail(key VARCHAR, something VARCHAR) \n" + "TYPE bigtable \n";
cli.execute(createTable);
Table table = metaStore.getTables().get("fail");
IllegalStateException e = assertThrows(IllegalStateException.class, () -> tableProvider.buildBeamSqlTable(table));
checkMessage(e.getMessage(), "LOCATION");
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigtableTableCreationFailuresTest method testCreatePropertiesDontMatchSchema.
@Test
public void testCreatePropertiesDontMatchSchema() {
String createTable = "CREATE EXTERNAL TABLE fail(key VARCHAR, q BIGINT, qq BINARY) \n" + "TYPE bigtable \n" + "LOCATION '" + location() + "' \n" + "TBLPROPERTIES '{\"columnsMapping\": \"f:b,f:c\"}'";
cli.execute(createTable);
Table table = metaStore.getTables().get("fail");
IllegalStateException e = assertThrows(IllegalStateException.class, () -> tableProvider.buildBeamSqlTable(table));
checkMessage(e.getMessage(), "does not fit to schema field names");
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BigtableTableCreationFailuresTest method testCreateWrongKeyTypeFails.
@Test
public void testCreateWrongKeyTypeFails() {
String createTable = "CREATE EXTERNAL TABLE fail(key FLOAT) \n" + "TYPE bigtable \n" + "LOCATION '" + location() + "'";
cli.execute(createTable);
Table table = metaStore.getTables().get("fail");
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> tableProvider.buildBeamSqlTable(table));
checkMessage(e.getMessage(), "key field type should be STRING but was FLOAT");
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class KafkaTableProviderIT method testFake2.
@Test
@SuppressWarnings("FutureReturnValueIgnored")
public void testFake2() throws BeamKafkaTable.NoEstimationException {
Table table = Table.builder().name("kafka_table").comment("kafka table").location(buildLocation()).schema(TEST_TABLE_SCHEMA).type("kafka").properties(JSON.parseObject(objectsProvider.getKafkaPropertiesString())).build();
BeamKafkaTable kafkaTable = (BeamKafkaTable) new KafkaTableProvider().buildBeamSqlTable(table);
produceSomeRecordsWithDelay(100, 20);
double rate1 = kafkaTable.computeRate(20);
produceSomeRecordsWithDelay(100, 10);
double rate2 = kafkaTable.computeRate(20);
Assert.assertTrue(rate2 > rate1);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class KafkaTableProviderTest method testBuildBeamSqlProtoTable.
@Test
public void testBuildBeamSqlProtoTable() {
Table table = mockProtoTable("hello", PayloadMessages.SimpleMessage.class);
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());
}
Aggregations