Search in sources :

Example 11 with BeamSqlTable

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

the class PubsubLiteTableProviderTest method topicTableCannotRead.

@Test
@SuppressWarnings("argument.type.incompatible")
public void topicTableCannotRead() {
    BeamSqlTable basic = makeTable(FULL_WRITE_SCHEMA, example(TopicPath.class).toString(), ImmutableMap.of());
    assertThrows(UnsupportedOperationException.class, () -> basic.buildIOReader(null));
}
Also used : BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Example 12 with BeamSqlTable

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

the class TestTableProviderTest method buildUp.

@Before
public void buildUp() {
    TestTableProvider tableProvider = new TestTableProvider();
    Table table = getTable("tableName");
    tableProvider.createTable(table);
    tableProvider.addRows(table.getName(), row(BASIC_SCHEMA, 1, "one"), row(BASIC_SCHEMA, 2, "two"));
    beamSqlTable = tableProvider.buildBeamSqlTable(table);
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Before(org.junit.Before)

Example 13 with BeamSqlTable

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

the class BigQueryTableProviderTest method testBuildBeamSqlTable.

@Test
public void testBuildBeamSqlTable() throws Exception {
    Table table = fakeTable("hello");
    BeamSqlTable sqlTable = provider.buildBeamSqlTable(table);
    assertNotNull(sqlTable);
    assertTrue(sqlTable instanceof BigQueryTable);
    BigQueryTable bqTable = (BigQueryTable) sqlTable;
    assertEquals("project:dataset.table", bqTable.bqLocation);
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Example 14 with BeamSqlTable

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

the class InMemoryMetaStoreTest method testBuildBeamSqlTable.

@Test
public void testBuildBeamSqlTable() throws Exception {
    Table table = mockTable("hello");
    store.createTable(table);
    BeamSqlTable actualSqlTable = store.buildBeamSqlTable(table);
    assertNotNull(actualSqlTable);
    assertEquals(Schema.builder().addNullableField("id", Schema.FieldType.INT32).addNullableField("name", Schema.FieldType.STRING).build(), actualSqlTable.getSchema());
}
Also used : Table(org.apache.beam.sdk.extensions.sql.meta.Table) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable) Test(org.junit.Test)

Example 15 with BeamSqlTable

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

the class BeamJoinRel method seekable.

/**
 * check if {@code BeamRelNode} implements {@code BeamSeekableTable}.
 */
public static boolean seekable(BeamRelNode relNode) {
    if (relNode instanceof BeamIOSourceRel) {
        BeamIOSourceRel srcRel = (BeamIOSourceRel) relNode;
        BeamSqlTable sourceTable = srcRel.getBeamSqlTable();
        if (sourceTable instanceof BeamSqlSeekableTable) {
            return true;
        }
    }
    return false;
}
Also used : BeamSqlSeekableTable(org.apache.beam.sdk.extensions.sql.BeamSqlSeekableTable) BeamSqlTable(org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable)

Aggregations

BeamSqlTable (org.apache.beam.sdk.extensions.sql.meta.BeamSqlTable)31 Test (org.junit.Test)25 Table (org.apache.beam.sdk.extensions.sql.meta.Table)21 Schema (org.apache.beam.sdk.schemas.Schema)5 BeamTableStatistics (org.apache.beam.sdk.extensions.sql.impl.BeamTableStatistics)3 DefaultTableFilter (org.apache.beam.sdk.extensions.sql.meta.DefaultTableFilter)2 Row (org.apache.beam.sdk.values.Row)2 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)2 JSONObject (com.alibaba.fastjson.JSONObject)1 TableFieldSchema (com.google.api.services.bigquery.model.TableFieldSchema)1 TableRow (com.google.api.services.bigquery.model.TableRow)1 TableSchema (com.google.api.services.bigquery.model.TableSchema)1 AutoService (com.google.auto.service.AutoService)1 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 PayloadMessages (org.apache.beam.sdk.extensions.protobuf.PayloadMessages)1 BeamSqlSeekableTable (org.apache.beam.sdk.extensions.sql.BeamSqlSeekableTable)1