use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamComplexTypeTest method testArrayWithRow.
@Test
public void testArrayWithRow() {
BeamSqlEnv sqlEnv = BeamSqlEnv.inMemory(readOnlyTableProvider);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, sqlEnv.parseQuery("SELECT arrayWithRowTestTable.col[1] FROM arrayWithRowTestTable"));
Schema outputSchema = Schema.builder().addRowField("col", innerRowSchema).build();
PAssert.that(stream).containsInAnyOrder(Row.withSchema(outputSchema).addValues(Row.withSchema(innerRowSchema).addValues("str", 1L).build()).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(2));
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamDDLTest method testParseCreateExternalTable_full.
@Test
public void testParseCreateExternalTable_full() 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" + "COMMENT 'person table' \n" + "LOCATION '/home/admin/person'\n" + "TBLPROPERTIES '{\"hello\": [\"james\", \"bond\"]}'");
assertEquals(mockTable("person", "text", "person table", properties), tableProvider.getTables().get("person"));
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamDDLTest method testParseCreateExternalTable_withDatabase.
@Test
public void testParseCreateExternalTable_withDatabase() throws Exception {
TestTableProvider rootProvider = new TestTableProvider();
TestTableProvider testProvider = new TestTableProvider();
BeamSqlEnv env = BeamSqlEnv.builder(rootProvider).addSchema("test", testProvider).setPipelineOptions(PipelineOptionsFactory.create()).build();
assertNull(testProvider.getTables().get("person"));
env.executeDdl("CREATE EXTERNAL TABLE test.person (id INT) TYPE text");
assertNotNull(testProvider.getTables().get("person"));
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamDDLTest method testParseCreateExternalTable_withoutType.
@Test(expected = ParseException.class)
public void testParseCreateExternalTable_withoutType() throws Exception {
BeamSqlEnv env = BeamSqlEnv.withTableProvider(new TestTableProvider());
env.executeDdl("CREATE EXTERNAL TABLE person (\n" + "id int COMMENT 'id', \n" + "name varchar COMMENT 'name') \n" + "COMMENT 'person table' \n" + "LOCATION '/home/admin/person'\n" + "TBLPROPERTIES '{\"hello\": [\"james\", \"bond\"]}'");
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamDDLTest method testParseCreateExternalTable_withoutLocation.
@Test
public void testParseCreateExternalTable_withoutLocation() 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");
assertEquals(mockTable("person", "text", "person table", new JSONObject(), null), tableProvider.getTables().get("person"));
}
Aggregations