use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class ThreeTablesSchema method testSystemReorderingLargeMediumSmall.
@Test
public void testSystemReorderingLargeMediumSmall() {
TestTableProvider tableProvider = new TestTableProvider();
createThreeTables(tableProvider);
BeamSqlEnv env = BeamSqlEnv.withTableProvider(tableProvider);
// This is Join(Join(large, medium), small) which should be converted to a join that large table
// is on the top.
BeamRelNode parsedQuery = env.parseQuery("select * from large_table " + " JOIN medium_table on large_table.medium_key = medium_table.large_key " + " JOIN small_table on medium_table.small_key = small_table.medium_key ");
assertTopTableInJoins(parsedQuery, "large_table");
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BigtableTableIT method writeData.
private void writeData() {
Pipeline p = Pipeline.create(options);
BeamSqlEnv sqlEnv = BeamSqlEnv.inMemory(new BigtableTableProvider());
sqlEnv.executeDdl(createFlatTableString(TABLE_ID, location()));
String query = String.format("INSERT INTO `%s`(key, boolColumn, longColumn, stringColumn, doubleColumn) " + "VALUES ('key1', FALSE, CAST(1 as bigint), 'string1', 1.0)", TABLE_ID);
BeamSqlRelUtils.toPCollection(p, sqlEnv.parseQuery(query));
p.run().waitUntilFinish();
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BigtableTableIT method readData.
private void readData() {
Pipeline p = Pipeline.create(options);
BeamSqlEnv sqlEnv = BeamSqlEnv.inMemory(new BigtableTableProvider());
sqlEnv.executeDdl(createFullTableString(TABLE_ID, location()));
String query = String.format("SELECT key, " + " t.familyTest.boolColumn, " + " t.familyTest.longColumn.val AS longValue, " + " t.familyTest.longColumn.timestampMicros, " + " t.familyTest.longColumn.labels, " + " t.familyTest.stringColumn, " + " t.familyTest.doubleColumn " + "FROM `%s` t", TABLE_ID);
PCollection<Row> rows = BeamSqlRelUtils.toPCollection(p, sqlEnv.parseQuery(query)).apply(MapElements.via(new ReplaceTimestamp())).setRowSchema(expectedFullSchema());
PAssert.that(rows).containsInAnyOrder(expectedFullRow(1));
p.run().waitUntilFinish();
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BigtableTableIT method readFlatData.
private void readFlatData() {
Pipeline p = Pipeline.create(options);
BeamSqlEnv sqlEnv = BeamSqlEnv.inMemory(new BigtableTableProvider());
sqlEnv.executeDdl(createFlatTableString(TABLE_ID, location()));
String query = "SELECT * FROM `" + TABLE_ID + "`";
PCollection<Row> flatRows = BeamSqlRelUtils.toPCollection(p, sqlEnv.parseQuery(query));
PAssert.that(flatRows).containsInAnyOrder(expectedFlatRow(1));
p.run().waitUntilFinish();
}
use of org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv in project beam by apache.
the class BigtableTableWithRowsTest method testSimpleSelect.
@Test
public void testSimpleSelect() {
createReadTable(TABLE, emulatorWrapper);
BeamSqlEnv sqlEnv = BeamSqlEnv.inMemory(new BigtableTableProvider());
sqlEnv.executeDdl(createFullTableString(TABLE, location()));
String query = "SELECT key, \n" + " bt.familyTest.boolColumn, \n" + " bt.familyTest.longColumn.val AS longValue, \n" + " bt.familyTest.longColumn.timestampMicros, \n" + " bt.familyTest.longColumn.labels, \n" + " bt.familyTest.stringColumn, \n" + " bt.familyTest.doubleColumn \n" + "FROM beamTable bt";
sqlEnv.parseQuery(query);
PCollection<Row> queryOutput = BeamSqlRelUtils.toPCollection(readPipeline, sqlEnv.parseQuery(query));
assertThat(queryOutput.getSchema(), equalTo(expectedFullSchema()));
PCollection<Row> sorted = queryOutput.apply(MapElements.via(new SortByTimestamp())).setRowSchema(expectedFullSchema());
PAssert.that(sorted).containsInAnyOrder(expectedFullRow(KEY1), expectedFullRow(KEY2));
readPipeline.run().waitUntilFinish();
}
Aggregations