use of org.apache.beam.sdk.extensions.sql.meta.store.InMemoryMetaStore in project beam by apache.
the class BeamSqlCliTest method testExecute_dropTable_assertTableRemovedFromPlanner.
@Test(expected = ParseException.class)
public void testExecute_dropTable_assertTableRemovedFromPlanner() 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'");
cli.execute("drop table person");
cli.explainQuery("select * from person");
}
use of org.apache.beam.sdk.extensions.sql.meta.store.InMemoryMetaStore in project beam by apache.
the class BeamSqlCliTest method testExplainQuery.
@Test
public void testExplainQuery() 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'");
String plan = cli.explainQuery("select * from person");
assertThat(plan, equalTo("BeamCalcRel(expr#0..2=[{inputs}], proj#0..2=[{exprs}])\n" + " BeamIOSourceRel(table=[[beam, person]])\n"));
}
use of org.apache.beam.sdk.extensions.sql.meta.store.InMemoryMetaStore 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.store.InMemoryMetaStore 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.store.InMemoryMetaStore in project beam by apache.
the class BeamSqlExplainTest method setUp.
@Before
public void setUp() throws SqlParseException, RelConversionException, ValidationException {
metaStore = new InMemoryMetaStore();
metaStore.registerProvider(new TextTableProvider());
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 '' ");
cli.execute("CREATE EXTERNAL TABLE A (\n" + "c1 int COMMENT 'c1',\n" + "c2 int COMMENT 'c2')\n" + "TYPE 'text'\n" + "COMMENT '' ");
cli.execute("CREATE EXTERNAL TABLE B (\n" + "c1 int COMMENT 'c1',\n" + "c2 int COMMENT 'c2')\n" + "TYPE 'text'\n" + "COMMENT '' ");
}
Aggregations