Search in sources :

Example 1 with TableTestUtil

use of org.apache.flink.table.planner.utils.TableTestUtil in project flink by apache.

the class JavaCatalogTableTest method testResolvingSchemaOfCustomCatalogTableTableApi.

@Test
public void testResolvingSchemaOfCustomCatalogTableTableApi() throws Exception {
    TableTestUtil testUtil = getTestUtil();
    TableEnvironment tableEnvironment = testUtil.getTableEnv();
    GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog("in-memory");
    genericInMemoryCatalog.createTable(new ObjectPath("default", "testTable"), new CustomCatalogTable(isStreamingMode), false);
    tableEnvironment.registerCatalog("testCatalog", genericInMemoryCatalog);
    Table table = tableEnvironment.from("testCatalog.`default`.testTable").window(Tumble.over(lit(10).minute()).on($("rowtime")).as("w")).groupBy($("w")).select(lit(1).count());
    testUtil.verifyExecPlan(table);
}
Also used : ObjectPath(org.apache.flink.table.catalog.ObjectPath) CatalogTable(org.apache.flink.table.catalog.CatalogTable) Table(org.apache.flink.table.api.Table) CatalogBaseTable(org.apache.flink.table.catalog.CatalogBaseTable) TableTestUtil(org.apache.flink.table.planner.utils.TableTestUtil) TableEnvironment(org.apache.flink.table.api.TableEnvironment) GenericInMemoryCatalog(org.apache.flink.table.catalog.GenericInMemoryCatalog) Test(org.junit.Test)

Example 2 with TableTestUtil

use of org.apache.flink.table.planner.utils.TableTestUtil in project flink by apache.

the class JavaCatalogTableTest method testResolvingProctimeOfCustomTableTableApi.

@Test
public void testResolvingProctimeOfCustomTableTableApi() throws Exception {
    if (!isStreamingMode) {
        // proctime not supported in batch
        return;
    }
    TableTestUtil testUtil = getTestUtil();
    TableEnvironment tableEnvironment = testUtil.getTableEnv();
    GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog("in-memory");
    genericInMemoryCatalog.createTable(new ObjectPath("default", "testTable"), new CustomCatalogTable(isStreamingMode), false);
    tableEnvironment.registerCatalog("testCatalog", genericInMemoryCatalog);
    Table table = tableEnvironment.from("testCatalog.`default`.testTable").window(Tumble.over(lit(10).minute()).on($("proctime")).as("w")).groupBy($("w")).select(lit(1).count());
    testUtil.verifyExecPlan(table);
}
Also used : ObjectPath(org.apache.flink.table.catalog.ObjectPath) CatalogTable(org.apache.flink.table.catalog.CatalogTable) Table(org.apache.flink.table.api.Table) CatalogBaseTable(org.apache.flink.table.catalog.CatalogBaseTable) TableTestUtil(org.apache.flink.table.planner.utils.TableTestUtil) TableEnvironment(org.apache.flink.table.api.TableEnvironment) GenericInMemoryCatalog(org.apache.flink.table.catalog.GenericInMemoryCatalog) Test(org.junit.Test)

Example 3 with TableTestUtil

use of org.apache.flink.table.planner.utils.TableTestUtil in project flink by apache.

the class JavaCatalogTableTest method testResolvingProctimeOfCustomTableSql.

@Test
public void testResolvingProctimeOfCustomTableSql() throws Exception {
    if (!isStreamingMode) {
        // proctime not supported in batch
        return;
    }
    TableTestUtil testUtil = getTestUtil();
    TableEnvironment tableEnvironment = testUtil.getTableEnv();
    GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog("in-memory");
    genericInMemoryCatalog.createTable(new ObjectPath("default", "testTable"), new CustomCatalogTable(isStreamingMode), false);
    tableEnvironment.registerCatalog("testCatalog", genericInMemoryCatalog);
    testUtil.verifyExecPlan("SELECT COUNT(*) FROM testCatalog.`default`.testTable " + "GROUP BY TUMBLE(proctime, INTERVAL '10' MINUTE)");
}
Also used : ObjectPath(org.apache.flink.table.catalog.ObjectPath) TableTestUtil(org.apache.flink.table.planner.utils.TableTestUtil) TableEnvironment(org.apache.flink.table.api.TableEnvironment) GenericInMemoryCatalog(org.apache.flink.table.catalog.GenericInMemoryCatalog) Test(org.junit.Test)

Example 4 with TableTestUtil

use of org.apache.flink.table.planner.utils.TableTestUtil in project flink by apache.

the class JavaCatalogTableTest method testResolvingSchemaOfCustomCatalogTableSql.

@Test
public void testResolvingSchemaOfCustomCatalogTableSql() throws Exception {
    TableTestUtil testUtil = getTestUtil();
    TableEnvironment tableEnvironment = testUtil.getTableEnv();
    GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog("in-memory");
    genericInMemoryCatalog.createTable(new ObjectPath("default", "testTable"), new CustomCatalogTable(isStreamingMode), false);
    tableEnvironment.registerCatalog("testCatalog", genericInMemoryCatalog);
    tableEnvironment.executeSql("CREATE VIEW testTable2 AS SELECT * FROM testCatalog.`default`.testTable");
    testUtil.verifyExecPlan("SELECT COUNT(*) FROM testTable2 GROUP BY TUMBLE(rowtime, INTERVAL '10' MINUTE)");
}
Also used : ObjectPath(org.apache.flink.table.catalog.ObjectPath) TableTestUtil(org.apache.flink.table.planner.utils.TableTestUtil) TableEnvironment(org.apache.flink.table.api.TableEnvironment) GenericInMemoryCatalog(org.apache.flink.table.catalog.GenericInMemoryCatalog) Test(org.junit.Test)

Aggregations

TableEnvironment (org.apache.flink.table.api.TableEnvironment)4 GenericInMemoryCatalog (org.apache.flink.table.catalog.GenericInMemoryCatalog)4 ObjectPath (org.apache.flink.table.catalog.ObjectPath)4 TableTestUtil (org.apache.flink.table.planner.utils.TableTestUtil)4 Test (org.junit.Test)4 Table (org.apache.flink.table.api.Table)2 CatalogBaseTable (org.apache.flink.table.catalog.CatalogBaseTable)2 CatalogTable (org.apache.flink.table.catalog.CatalogTable)2