use of org.apache.flink.table.catalog.ObjectPath 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);
}
use of org.apache.flink.table.catalog.ObjectPath 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);
}
use of org.apache.flink.table.catalog.ObjectPath 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)");
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class CatalogITCase method testGetTablesFromGivenCatalogDatabase.
@Test
public void testGetTablesFromGivenCatalogDatabase() throws Exception {
final Catalog c1 = new GenericInMemoryCatalog("c1", "default");
final Catalog c2 = new GenericInMemoryCatalog("c2", "d2");
final CatalogManager catalogManager = CatalogManagerMocks.preparedCatalogManager().defaultCatalog("c2", c2).build();
catalogManager.registerCatalog("c1", c1);
final CatalogTable catalogTable = CatalogTable.of(Schema.newBuilder().build(), null, new ArrayList<>(), new HashMap<>());
c1.createDatabase("d1", new CatalogDatabaseImpl(new HashMap<>(), null), true);
c1.createTable(new ObjectPath("d1", "t1"), catalogTable, true);
c2.createTable(new ObjectPath(catalogManager.getCurrentDatabase(), "t2"), catalogTable, true);
assertThat(catalogManager.getCurrentCatalog()).isEqualTo("c2");
assertThat(catalogManager.getCurrentDatabase()).isEqualTo("d2");
assertThat(catalogManager.listTables()).containsExactlyInAnyOrder("t2");
assertThat(catalogManager.listTables("c1", "d1")).containsExactlyInAnyOrder("t1");
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class CatalogStatisticsTest method createPartitionStats.
private void createPartitionStats(String part1, int part2, long rowCount) throws Exception {
ObjectPath path = ObjectPath.fromString("default_database.PartT");
LinkedHashMap<String, String> partSpecMap = new LinkedHashMap<>();
partSpecMap.put("part1", part1);
partSpecMap.put("part2", String.valueOf(part2));
CatalogPartitionSpec partSpec = new CatalogPartitionSpec(partSpecMap);
catalog.createPartition(path, partSpec, new CatalogPartitionImpl(new HashMap<>(), ""), true);
catalog.alterPartitionStatistics(path, partSpec, new CatalogTableStatistics(rowCount, 10, 1000L, 2000L), true);
}
Aggregations