LadyForest commented on code in PR #173: URL: https://github.com/apache/flink-table-store/pull/173#discussion_r905039136
########## flink-table-store-core/src/main/java/org/apache/flink/table/store/file/catalog/Catalog.java: ########## @@ -0,0 +1,184 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.store.file.catalog; + +import org.apache.flink.core.fs.Path; +import org.apache.flink.table.catalog.ObjectPath; +import org.apache.flink.table.store.file.schema.TableSchema; +import org.apache.flink.table.store.file.schema.UpdateSchema; + +import java.util.List; + +/** + * This interface is responsible for reading and writing metadata such as database/table from a + * table store catalog. + */ +public interface Catalog extends AutoCloseable { + + /** + * Get the names of all databases in this catalog. + * + * @return a list of the names of all databases + */ + List<String> listDatabases(); + + /** + * Drop a database. + * + * @param name Name of the database to be dropped. + * @param cascade Flag to specify behavior when the database contains table or function: if set + * to true, delete all tables and functions in the database and then delete the database, if + * set to false, throw an exception. + * @throws DatabaseNotEmptyException if the given database is not empty and isRestrict is true + */ + void dropDatabase(String name, boolean cascade) throws DatabaseNotEmptyException; + + /** + * Get names of all tables under this database. An empty list is returned if none exists. + * + * @return a list of the names of all tables in this database + */ + List<String> listTables(String databaseName); + + /** + * Returns the table location path identified by the given {@link ObjectPath}. + * + * @param tablePath Path of the table + * @return The requested table location + */ + Path getTableLocation(ObjectPath tablePath); + + /** + * Returns a {@link TableSchema} identified by the given {@link ObjectPath}. Review Comment: Ditto ########## flink-table-store-core/src/main/java/org/apache/flink/table/store/file/catalog/Catalog.java: ########## @@ -0,0 +1,184 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.store.file.catalog; + +import org.apache.flink.core.fs.Path; +import org.apache.flink.table.catalog.ObjectPath; +import org.apache.flink.table.store.file.schema.TableSchema; +import org.apache.flink.table.store.file.schema.UpdateSchema; + +import java.util.List; + +/** + * This interface is responsible for reading and writing metadata such as database/table from a + * table store catalog. + */ +public interface Catalog extends AutoCloseable { + + /** + * Get the names of all databases in this catalog. + * + * @return a list of the names of all databases + */ + List<String> listDatabases(); + + /** + * Drop a database. + * + * @param name Name of the database to be dropped. + * @param cascade Flag to specify behavior when the database contains table or function: if set + * to true, delete all tables and functions in the database and then delete the database, if + * set to false, throw an exception. + * @throws DatabaseNotEmptyException if the given database is not empty and isRestrict is true + */ + void dropDatabase(String name, boolean cascade) throws DatabaseNotEmptyException; + + /** + * Get names of all tables under this database. An empty list is returned if none exists. + * + * @return a list of the names of all tables in this database + */ + List<String> listTables(String databaseName); + + /** + * Returns the table location path identified by the given {@link ObjectPath}. + * + * @param tablePath Path of the table + * @return The requested table location + */ + Path getTableLocation(ObjectPath tablePath); + + /** + * Returns a {@link TableSchema} identified by the given {@link ObjectPath}. + * + * @param tablePath Path of the table + * @return The requested table + * @throws TableNotExistException if the target does not exist + */ + TableSchema getTable(ObjectPath tablePath) throws TableNotExistException; + + /** + * Check if a table exists in this catalog. + * + * @param tablePath Path of the table + * @return true if the given table exists in the catalog false otherwise + */ + boolean tableExists(ObjectPath tablePath); + + /** + * Drop a table. + * + * @param tablePath Path of the table to be dropped + * @param ignoreIfNotExists Flag to specify behavior when the table does not exist: if set to + * false, throw an exception, if set to true, do nothing. + * @throws TableNotExistException if the table does not exist + */ + void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists) throws TableNotExistException; + + /** + * Creates a new table. Review Comment: Ditto -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
