Search in sources :

Example 1 with BeamSqlCli

use of org.apache.beam.sdk.extensions.sql.BeamSqlCli in project beam by apache.

the class BigtableTableFlatTest method testCreatesFlatSchemaCorrectly.

@Test
public void testCreatesFlatSchemaCorrectly() {
    final String tableId = "flatTableSchema";
    InMemoryMetaStore metaStore = new InMemoryMetaStore();
    metaStore.registerProvider(new BigtableTableProvider());
    BeamSqlCli cli = new BeamSqlCli().metaStore(metaStore);
    cli.execute(createFlatTableString(tableId, location(tableId)));
    Table table = metaStore.getTables().get(tableId);
    assertNotNull(table);
    assertEquals(TEST_FLAT_SCHEMA, table.getSchema());
    JSONObject properties = table.getProperties();
    assertTrue(properties.containsKey(COLUMNS_MAPPING));
    assertEquals(columnsMappingString(), properties.getString(COLUMNS_MAPPING));
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BigtableTableTestUtils.createReadTable(org.apache.beam.sdk.extensions.sql.meta.provider.bigtable.BigtableTableTestUtils.createReadTable) JSONObject(com.alibaba.fastjson.JSONObject) BeamSqlCli(org.apache.beam.sdk.extensions.sql.BeamSqlCli) BigtableTableTestUtils.columnsMappingString(org.apache.beam.sdk.extensions.sql.meta.provider.bigtable.BigtableTableTestUtils.columnsMappingString) BigtableTableTestUtils.createFlatTableString(org.apache.beam.sdk.extensions.sql.meta.provider.bigtable.BigtableTableTestUtils.createFlatTableString) InMemoryMetaStore(org.apache.beam.sdk.extensions.sql.meta.store.InMemoryMetaStore) Test(org.junit.Test)

Example 2 with BeamSqlCli

use of org.apache.beam.sdk.extensions.sql.BeamSqlCli in project beam by apache.

the class BigtableTableWithRowsTest method testCreatesSchemaCorrectly.

@Test
public void testCreatesSchemaCorrectly() {
    InMemoryMetaStore metaStore = new InMemoryMetaStore();
    metaStore.registerProvider(new BigtableTableProvider());
    BeamSqlCli cli = new BeamSqlCli().metaStore(metaStore);
    cli.execute(createFullTableString(TABLE, location()));
    Table table = metaStore.getTables().get("beamTable");
    assertNotNull(table);
    assertEquals(TEST_SCHEMA, table.getSchema());
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BigtableTableTestUtils.createReadTable(org.apache.beam.sdk.extensions.sql.meta.provider.bigtable.BigtableTableTestUtils.createReadTable) BeamSqlCli(org.apache.beam.sdk.extensions.sql.BeamSqlCli) InMemoryMetaStore(org.apache.beam.sdk.extensions.sql.meta.store.InMemoryMetaStore) Test(org.junit.Test)

Aggregations

BeamSqlCli (org.apache.beam.sdk.extensions.sql.BeamSqlCli)2 Table (org.apache.beam.sdk.extensions.sql.meta.Table)2 BigtableTableTestUtils.createReadTable (org.apache.beam.sdk.extensions.sql.meta.provider.bigtable.BigtableTableTestUtils.createReadTable)2 InMemoryMetaStore (org.apache.beam.sdk.extensions.sql.meta.store.InMemoryMetaStore)2 Test (org.junit.Test)2 JSONObject (com.alibaba.fastjson.JSONObject)1 BigtableTableTestUtils.columnsMappingString (org.apache.beam.sdk.extensions.sql.meta.provider.bigtable.BigtableTableTestUtils.columnsMappingString)1 BigtableTableTestUtils.createFlatTableString (org.apache.beam.sdk.extensions.sql.meta.provider.bigtable.BigtableTableTestUtils.createFlatTableString)1