use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamDDLTest method testParseCreateTable.
@Test(expected = ParseException.class)
public void testParseCreateTable() throws Exception {
BeamSqlEnv env = BeamSqlEnv.withTableProvider(new TestTableProvider());
env.executeDdl("CREATE 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\"]}'");
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamDDLTest method testParseCreateExternalTable_minimal.
@Test
public void testParseCreateExternalTable_minimal() throws Exception {
TestTableProvider tableProvider = new TestTableProvider();
BeamSqlEnv env = BeamSqlEnv.withTableProvider(tableProvider);
env.executeDdl("CREATE EXTERNAL TABLE person (id INT) TYPE text");
assertEquals(Table.builder().name("person").type("text").schema(Stream.of(Schema.Field.of("id", CalciteUtils.INTEGER).withNullable(true)).collect(toSchema())).properties(new JSONObject()).build(), tableProvider.getTables().get("person"));
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamDDLTest method testParseDropTable.
@Test
public void testParseDropTable() throws Exception {
TestTableProvider tableProvider = new TestTableProvider();
BeamSqlEnv env = BeamSqlEnv.withTableProvider(tableProvider);
assertNull(tableProvider.getTables().get("person"));
env.executeDdl("CREATE EXTERNAL TABLE person (\n" + "id int COMMENT 'id', \n" + "name varchar COMMENT 'name') \n" + "TYPE 'text' \n" + "COMMENT 'person table' \n");
assertNotNull(tableProvider.getTables().get("person"));
env.executeDdl("drop table person");
assertNull(tableProvider.getTables().get("person"));
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamComplexTypeTest method testNestedArray.
@Test
public void testNestedArray() {
BeamSqlEnv sqlEnv = BeamSqlEnv.inMemory(readOnlyTableProvider);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, sqlEnv.parseQuery("SELECT nestedArrayTestTable.col[1][3], nestedArrayTestTable.col[2][1] FROM nestedArrayTestTable"));
PAssert.that(stream).containsInAnyOrder(Row.withSchema(Schema.builder().addInt64Field("field1").addInt64Field("field2").build()).addValues(3L, 4L).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(2));
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BeamComplexTypeTest method testFieldAccessToNestedRow.
@Test
public void testFieldAccessToNestedRow() {
BeamSqlEnv sqlEnv = BeamSqlEnv.inMemory(readOnlyTableProvider);
PCollection<Row> stream = BeamSqlRelUtils.toPCollection(pipeline, sqlEnv.parseQuery("SELECT nestedRowTestTable.col.RowField.string_field, nestedRowTestTable.col.RowFieldTwo.long_field FROM nestedRowTestTable"));
PAssert.that(stream).containsInAnyOrder(Row.withSchema(Schema.builder().addStringField("field1").addInt64Field("field2").build()).addValues("inner_str_one", 3L).build());
pipeline.run().waitUntilFinish(Duration.standardMinutes(2));
}
Aggregations