use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider in project beam by apache.
the class BigtableFilterTest method buildUp.
@Before
public void buildUp() {
TestTableProvider tableProvider = new TestTableProvider();
Table table = getTable("TEST", PushDownOptions.NONE);
tableProvider.createTable(table);
tableProvider.addRows(table.getName(), row("key1", "firstName"), row("key2", "secondName"));
sqlEnv = BeamSqlEnv.builder(tableProvider).setPipelineOptions(PipelineOptionsFactory.create()).build();
}
use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider in project beam by apache.
the class JdbcDriverTest method testSelectsFromExistingComplexTable.
@Test
public void testSelectsFromExistingComplexTable() throws Exception {
TestTableProvider tableProvider = new TestTableProvider();
Connection connection = JdbcDriver.connect(tableProvider, PipelineOptionsFactory.create());
connection.createStatement().executeUpdate("CREATE EXTERNAL TABLE person ( \n" + "description VARCHAR, \n" + "nestedRow ROW< \n" + " id BIGINT, \n" + " name VARCHAR> \n" + ") \n" + "TYPE 'test'");
tableProvider.addRows("person", row(COMPLEX_SCHEMA, "description1", row(1L, "aaa")), row(COMPLEX_SCHEMA, "description2", row(2L, "bbb")));
ResultSet selectResult = connection.createStatement().executeQuery("SELECT person.nestedRow.id, person.nestedRow.name FROM person");
List<Row> resultRows = readResultSet(selectResult).stream().map(values -> values.stream().collect(toRow(BASIC_SCHEMA))).collect(Collectors.toList());
assertThat(resultRows, containsInAnyOrder(row(1L, "aaa"), row(2L, "bbb")));
}
use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider in project beam by apache.
the class BeamDDLTest method testParseCreateExternalTable_withoutTableComment.
@Test
public void testParseCreateExternalTable_withoutTableComment() throws Exception {
TestTableProvider tableProvider = new TestTableProvider();
BeamSqlEnv env = BeamSqlEnv.withTableProvider(tableProvider);
JSONObject properties = new JSONObject();
JSONArray hello = new JSONArray();
hello.add("james");
hello.add("bond");
properties.put("hello", hello);
env.executeDdl("CREATE EXTERNAL TABLE person (\n" + "id int COMMENT 'id', \n" + "name varchar COMMENT 'name') \n" + "TYPE 'text' \n" + "LOCATION '/home/admin/person'\n" + "TBLPROPERTIES '{\"hello\": [\"james\", \"bond\"]}'");
assertEquals(mockTable("person", "text", null, properties), tableProvider.getTables().get("person"));
}
use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider in project beam by apache.
the class BeamDDLTest method testParseCreateExternalTable_withoutTblProperties.
@Test
public void testParseCreateExternalTable_withoutTblProperties() throws Exception {
TestTableProvider tableProvider = new TestTableProvider();
BeamSqlEnv env = BeamSqlEnv.withTableProvider(tableProvider);
env.executeDdl("CREATE EXTERNAL TABLE person (\n" + "id int COMMENT 'id', \n" + "name varchar COMMENT 'name') \n" + "TYPE 'text' \n" + "COMMENT 'person table' \n" + "LOCATION '/home/admin/person'\n");
assertEquals(mockTable("person", "text", "person table", new JSONObject()), tableProvider.getTables().get("person"));
}
use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider in project beam by apache.
the class BeamDDLTest method testParseCreateExternalTable_WithComplexFields.
@Test
public void testParseCreateExternalTable_WithComplexFields() {
TestTableProvider tableProvider = new TestTableProvider();
BeamSqlEnv env = BeamSqlEnv.withTableProvider(tableProvider);
env.executeDdl("CREATE EXTERNAL TABLE PersonDetails" + " ( personInfo MAP<VARCHAR, ROW<field_1 INTEGER,field_2 VARCHAR>> , " + " additionalInfo ROW<field_0 TIMESTAMP,field_1 INTEGER,field_2 TINYINT> )" + " TYPE 'text'" + " LOCATION '/home/admin/person'");
assertNotNull(tableProvider.getTables().get("PersonDetails"));
}
Aggregations