use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BeamSqlCliTest method testExecute_createTextTable.
@Test
public void testExecute_createTextTable() throws Exception {
InMemoryMetaStore metaStore = new InMemoryMetaStore();
metaStore.registerProvider(new TextTableProvider());
BeamSqlCli cli = new BeamSqlCli().metaStore(metaStore);
cli.execute("CREATE EXTERNAL TABLE person (\n" + "id int COMMENT 'id', \n" + "name varchar COMMENT 'name', \n" + "age int COMMENT 'age') \n" + "TYPE 'text' \n" + "COMMENT '' LOCATION '/home/admin/orders'");
Table table = metaStore.getTables().get("person");
assertNotNull(table);
assertEquals(Stream.of(Field.of("id", INTEGER).withDescription("id").withNullable(true), Field.of("name", VARCHAR).withDescription("name").withNullable(true), Field.of("age", INTEGER).withDescription("age").withNullable(true)).collect(toSchema()), table.getSchema());
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class BeamSqlCliTest method testExecute_dropTable.
@Test
public void testExecute_dropTable() throws Exception {
InMemoryMetaStore metaStore = new InMemoryMetaStore();
metaStore.registerProvider(new TextTableProvider());
BeamSqlCli cli = new BeamSqlCli().metaStore(metaStore);
cli.execute("CREATE EXTERNAL TABLE person (\n" + "id int COMMENT 'id', \n" + "name varchar COMMENT 'name', \n" + "age int COMMENT 'age') \n" + "TYPE 'text' \n" + "COMMENT '' LOCATION '/home/admin/orders'");
Table table = metaStore.getTables().get("person");
assertNotNull(table);
cli.execute("drop table person");
table = metaStore.getTables().get("person");
assertNull(table);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class TestTableProviderWithProjectPushDown method buildUp.
@Before
public void buildUp() {
TestTableProvider tableProvider = new TestTableProvider();
Table table = getTable("TEST", PushDownOptions.PROJECT);
tableProvider.createTable(table);
tableProvider.addRows(table.getName(), row(BASIC_SCHEMA, 100, 1, "one", 100), row(BASIC_SCHEMA, 200, 2, "two", 200));
sqlEnv = BeamSqlEnv.builder(tableProvider).setPipelineOptions(PipelineOptionsFactory.create()).setRuleSets(ImmutableList.of(RuleSets.ofList(rulesWithPushDown))).build();
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class InMemoryMetaStoreTest method testCreateTable_invalidTableType.
@Test(expected = IllegalArgumentException.class)
public void testCreateTable_invalidTableType() throws Exception {
Table table = mockTable("person", "invalid");
store.createTable(table);
}
use of org.apache.beam.sdk.extensions.sql.meta.Table in project beam by apache.
the class InMemoryMetaStoreTest method testCreateTable.
@Test
public void testCreateTable() throws Exception {
Table table = mockTable("person");
store.createTable(table);
Table actualTable = store.getTables().get("person");
assertEquals(table, actualTable);
}
Aggregations