Search in sources :

Example 16 with TestTableProvider

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

the class BeamDDLTest method testParseCreateExternalTable_withoutType.

@Test(expected = ParseException.class)
public void testParseCreateExternalTable_withoutType() throws Exception {
    BeamSqlEnv env = BeamSqlEnv.withTableProvider(new TestTableProvider());
    env.executeDdl("CREATE EXTERNAL TABLE person (\n" + "id int COMMENT 'id', \n" + "name varchar COMMENT 'name') \n" + "COMMENT 'person table' \n" + "LOCATION '/home/admin/person'\n" + "TBLPROPERTIES '{\"hello\": [\"james\", \"bond\"]}'");
}
Also used : TestTableProvider(org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider) BeamSqlEnv(org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv) Test(org.junit.Test)

Example 17 with TestTableProvider

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

the class BeamDDLTest method testParseCreateExternalTable_withoutLocation.

@Test
public void testParseCreateExternalTable_withoutLocation() throws Exception {
    TestTableProvider tableProvider = new TestTableProvider();
    BeamSqlEnv env = BeamSqlEnv.withTableProvider(tableProvider);
    env.executeDdl("CREATE EXTERNAL TABLE person (\n" + "id int COMMENT 'id', \n" + "name varchar COMMENT 'name') \n" + "TYPE 'text' \n" + "COMMENT 'person table' \n");
    assertEquals(mockTable("person", "text", "person table", new JSONObject(), null), tableProvider.getTables().get("person"));
}
Also used : TestTableProvider(org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider) JSONObject(com.alibaba.fastjson.JSONObject) BeamSqlEnv(org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv) Test(org.junit.Test)

Example 18 with TestTableProvider

use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider 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\"]}'");
}
Also used : TestTableProvider(org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider) BeamSqlEnv(org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv) Test(org.junit.Test)

Example 19 with TestTableProvider

use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider 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"));
}
Also used : TestTableProvider(org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider) JSONObject(com.alibaba.fastjson.JSONObject) BeamSqlEnv(org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv) Test(org.junit.Test)

Example 20 with TestTableProvider

use of org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider 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"));
}
Also used : TestTableProvider(org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider) BeamSqlEnv(org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv) Test(org.junit.Test)

Aggregations

TestTableProvider (org.apache.beam.sdk.extensions.sql.meta.provider.test.TestTableProvider)32 Test (org.junit.Test)25 BeamSqlEnv (org.apache.beam.sdk.extensions.sql.impl.BeamSqlEnv)16 Before (org.junit.Before)8 Connection (java.sql.Connection)7 ResultSet (java.sql.ResultSet)7 Table (org.apache.beam.sdk.extensions.sql.meta.Table)7 Timestamp (java.sql.Timestamp)6 Schema (org.apache.beam.sdk.schemas.Schema)6 Row (org.apache.beam.sdk.values.Row)6 CalciteConnection (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.CalciteConnection)6 CalciteSchema (org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.jdbc.CalciteSchema)6 ReadableInstant (org.joda.time.ReadableInstant)6 JSONObject (com.alibaba.fastjson.JSONObject)5 Calendar (java.util.Calendar)5 BeamRelNode (org.apache.beam.sdk.extensions.sql.impl.rel.BeamRelNode)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Map (java.util.Map)4 Collectors (java.util.stream.Collectors)4