use of org.apache.flink.table.catalog.ObjectPath 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)");
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class CatalogConstraintTest method testWithoutPrimaryKey.
@Test
public void testWithoutPrimaryKey() throws Exception {
TableSchema tableSchema = TableSchema.builder().fields(new String[] { "a", "b", "c" }, new DataType[] { DataTypes.BIGINT(), DataTypes.STRING(), DataTypes.INT() }).build();
Map<String, String> properties = buildCatalogTableProperties(tableSchema);
catalog.createTable(new ObjectPath(databaseName, "T1"), new CatalogTableImpl(tableSchema, properties, ""), false);
RelNode t1 = TableTestUtil.toRelNode(tEnv.sqlQuery("select * from T1"));
FlinkRelMetadataQuery mq = FlinkRelMetadataQuery.reuseOrCreate(t1.getCluster().getMetadataQuery());
assertEquals(ImmutableSet.of(), mq.getUniqueKeys(t1));
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class CatalogConstraintTest method testWithPrimaryKey.
@Test
public void testWithPrimaryKey() throws Exception {
TableSchema tableSchema = TableSchema.builder().fields(new String[] { "a", "b", "c" }, new DataType[] { DataTypes.STRING(), DataTypes.BIGINT().notNull(), DataTypes.INT() }).primaryKey("b").build();
Map<String, String> properties = buildCatalogTableProperties(tableSchema);
catalog.createTable(new ObjectPath(databaseName, "T1"), new CatalogTableImpl(tableSchema, properties, ""), false);
RelNode t1 = TableTestUtil.toRelNode(tEnv.sqlQuery("select * from T1"));
FlinkRelMetadataQuery mq = FlinkRelMetadataQuery.reuseOrCreate(t1.getCluster().getMetadataQuery());
assertEquals(ImmutableSet.of(ImmutableBitSet.of(1)), mq.getUniqueKeys(t1));
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class CatalogStatisticsTest method testGetStatsFromCatalogForCatalogTableImpl.
@Test
public void testGetStatsFromCatalogForCatalogTableImpl() throws Exception {
Map<String, String> properties = new HashMap<>();
properties.put("connector.type", "filesystem");
properties.put("connector.property-version", "1");
properties.put("connector.path", "/path/to/csv");
properties.put("format.type", "csv");
properties.put("format.property-version", "1");
properties.put("format.field-delimiter", ";");
catalog.createTable(new ObjectPath(databaseName, "T1"), new CatalogTableImpl(tableSchema, properties, ""), false);
catalog.createTable(new ObjectPath(databaseName, "T2"), new CatalogTableImpl(tableSchema, properties, ""), false);
alterTableStatistics(catalog, "T1");
assertStatistics(tEnv, "T1");
alterTableStatisticsWithUnknownRowCount(catalog, "T2");
assertTableStatisticsWithUnknownRowCount(tEnv, "T2");
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class CatalogStatisticsTest method alterTableStatistics.
private void alterTableStatistics(Catalog catalog, String tableName) throws TableNotExistException, TablePartitionedException {
catalog.alterTableStatistics(new ObjectPath(databaseName, tableName), new CatalogTableStatistics(100, 10, 1000L, 2000L), true);
catalog.alterTableColumnStatistics(new ObjectPath(databaseName, tableName), createColumnStats(), true);
}
Aggregations