use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class MySqlCatalogITCase method testGetTables_TableNotExistException.
@Test
public void testGetTables_TableNotExistException() throws TableNotExistException {
String anyTableNotExist = "anyTable";
assertThatThrownBy(() -> catalog.getTable(new ObjectPath(TEST_DB, anyTableNotExist))).satisfies(anyCauseMatches(TableNotExistException.class, String.format("Table (or view) %s.%s does not exist in Catalog", TEST_DB, anyTableNotExist)));
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class TableEnvironmentTest method testCreateTableFromDescriptor.
@Test
public void testCreateTableFromDescriptor() throws Exception {
final TableEnvironmentMock tEnv = TableEnvironmentMock.getStreamingInstance();
final String catalog = tEnv.getCurrentCatalog();
final String database = tEnv.getCurrentDatabase();
final Schema schema = Schema.newBuilder().column("f0", DataTypes.INT()).build();
tEnv.createTable("T", TableDescriptor.forConnector("fake").schema(schema).option("a", "Test").build());
final ObjectPath objectPath = new ObjectPath(database, "T");
assertThat(tEnv.getCatalog(catalog).orElseThrow(AssertionError::new).tableExists(objectPath)).isTrue();
final CatalogBaseTable catalogTable = tEnv.getCatalog(catalog).orElseThrow(AssertionError::new).getTable(objectPath);
assertThat(catalogTable).isInstanceOf(CatalogTable.class);
assertThat(catalogTable.getUnresolvedSchema()).isEqualTo(schema);
assertThat(catalogTable.getOptions()).contains(entry("connector", "fake"), entry("a", "Test"));
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class SqlToOperationConverterTest method after.
@After
public void after() throws TableNotExistException {
final ObjectPath path1 = new ObjectPath(catalogManager.getCurrentDatabase(), "t1");
final ObjectPath path2 = new ObjectPath(catalogManager.getCurrentDatabase(), "t2");
catalog.dropTable(path1, true);
catalog.dropTable(path2, true);
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class FunctionITCase method testAlterFunction.
@Test
public void testAlterFunction() throws Exception {
String create = "create function f3 as 'org.apache.flink.function.TestFunction'";
String alter = "alter function f3 as 'org.apache.flink.function.TestFunction2'";
ObjectPath objectPath = new ObjectPath("default_database", "f3");
assertTrue(tEnv().getCatalog("default_catalog").isPresent());
Catalog catalog = tEnv().getCatalog("default_catalog").get();
tEnv().executeSql(create);
CatalogFunction beforeUpdate = catalog.getFunction(objectPath);
assertEquals("org.apache.flink.function.TestFunction", beforeUpdate.getClassName());
tEnv().executeSql(alter);
CatalogFunction afterUpdate = catalog.getFunction(objectPath);
assertEquals("org.apache.flink.function.TestFunction2", afterUpdate.getClassName());
}
use of org.apache.flink.table.catalog.ObjectPath in project flink by apache.
the class DatabaseCalciteSchema method extractTableStats.
private TableStats extractTableStats(ContextResolvedTable lookupResult, ObjectIdentifier identifier) {
if (lookupResult.isTemporary()) {
return TableStats.UNKNOWN;
}
final Catalog catalog = lookupResult.getCatalog().orElseThrow(IllegalStateException::new);
final ObjectPath tablePath = identifier.toObjectPath();
try {
final CatalogTableStatistics tableStatistics = catalog.getTableStatistics(tablePath);
final CatalogColumnStatistics columnStatistics = catalog.getTableColumnStatistics(tablePath);
return convertToTableStats(tableStatistics, columnStatistics);
} catch (TableNotExistException e) {
throw new ValidationException(format("Could not get statistic for table: [%s, %s, %s]", identifier.getCatalogName(), tablePath.getDatabaseName(), tablePath.getObjectName()), e);
}
}
Aggregations