Search in sources :

Example 1 with TestBoundedTable

use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestBoundedTable in project beam by apache.

the class CustomTableResolverTest method testDefaultBuildIOReader_withEmptyParams_returnsPCollection.

@Test
public void testDefaultBuildIOReader_withEmptyParams_returnsPCollection() {
    TestBoundedTable testTable = TestBoundedTable.of(BASIC_SCHEMA).addRows(1, "one");
    Row expected = row(1, "one");
    PCollection<Row> resultWithEmpty = testTable.buildIOReader(pipeline.begin(), testTable.constructFilter(ImmutableList.of()), ImmutableList.of());
    PAssert.that(resultWithEmpty).containsInAnyOrder(expected);
    pipeline.run().waitUntilFinish(Duration.standardMinutes(2));
}
Also used : TestBoundedTable(org.apache.beam.sdk.extensions.sql.meta.provider.test.TestBoundedTable) Row(org.apache.beam.sdk.values.Row) Test(org.junit.Test)

Example 2 with TestBoundedTable

use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestBoundedTable in project beam by apache.

the class CustomTableResolverTest method testDefaultBuildIOReader_withNonEmptyParams_throwsException.

@Test
public void testDefaultBuildIOReader_withNonEmptyParams_throwsException() {
    TestBoundedTable testTable = TestBoundedTable.of(BASIC_SCHEMA).addRows(1, "one");
    assertThrows(UnsupportedOperationException.class, () -> testTable.buildIOReader(pipeline.begin(), new BeamSqlTableFilter() {

        @Override
        public List<RexNode> getNotSupported() {
            return null;
        }

        @Override
        public int numSupported() {
            return 0;
        }
    }, ImmutableList.of()));
    assertThrows(UnsupportedOperationException.class, () -> testTable.buildIOReader(pipeline.begin(), new DefaultTableFilter(ImmutableList.of()), ImmutableList.of("one")));
    pipeline.run().waitUntilFinish(Duration.standardMinutes(2));
}
Also used : TestBoundedTable(org.apache.beam.sdk.extensions.sql.meta.provider.test.TestBoundedTable) RexNode(org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexNode) Test(org.junit.Test)

Example 3 with TestBoundedTable

use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestBoundedTable in project beam by apache.

the class TestBoundedTableTest method testCreatingEmptyTable.

@Test
public void testCreatingEmptyTable() {
    TestBoundedTable emptyTable = TestBoundedTable.of(Schema.builder().addInt32Field("ColId").addStringField("Value").build());
    emptyTable.buildIOReader(PBegin.in(pipeline));
    pipeline.run();
}
Also used : TestBoundedTable(org.apache.beam.sdk.extensions.sql.meta.provider.test.TestBoundedTable) Test(org.junit.Test)

Aggregations

TestBoundedTable (org.apache.beam.sdk.extensions.sql.meta.provider.test.TestBoundedTable)3 Test (org.junit.Test)3 Row (org.apache.beam.sdk.values.Row)1 RexNode (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexNode)1