rdblue commented on code in PR #7913: URL: https://github.com/apache/iceberg/pull/7913#discussion_r1342176105
########## api/src/main/java/org/apache/iceberg/catalog/ViewSessionCatalog.java: ########## @@ -0,0 +1,119 @@ +/* + * 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.iceberg.catalog; + +import java.util.List; +import java.util.Map; +import org.apache.iceberg.exceptions.AlreadyExistsException; +import org.apache.iceberg.exceptions.NoSuchNamespaceException; +import org.apache.iceberg.exceptions.NoSuchViewException; +import org.apache.iceberg.view.View; +import org.apache.iceberg.view.ViewBuilder; + +/** A session Catalog API for view create, drop, and load operations. */ +public interface ViewSessionCatalog { + + /** + * Return the name for this catalog. + * + * @return this catalog's name + */ + String name(); + + /** + * Return all the identifiers under this namespace. + * + * @param namespace a namespace + * @return a list of identifiers for views + * @throws NoSuchNamespaceException if the namespace is not found + */ + List<TableIdentifier> listViews(SessionCatalog.SessionContext context, Namespace namespace); + + /** + * Load a view. + * + * @param identifier a view identifier + * @return instance of {@link View} implementation referred by the identifier + * @throws NoSuchViewException if the view does not exist + */ + View loadView(SessionCatalog.SessionContext context, TableIdentifier identifier); + + /** + * Check whether view exists. + * + * @param identifier a view identifier + * @return true if the view exists, false otherwise + */ + default boolean viewExists(SessionCatalog.SessionContext context, TableIdentifier identifier) { + try { + loadView(context, identifier); + return true; + } catch (NoSuchViewException e) { + return false; + } + } + + /** + * Instantiate a builder to create or replace a SQL view. + * + * @param identifier a view identifier + * @return a view builder + */ + ViewBuilder buildView(SessionCatalog.SessionContext context, TableIdentifier identifier); + + /** + * Drop a view. + * + * @param identifier a view identifier + * @return true if the view was dropped, false if the view did not exist + */ + boolean dropView(SessionCatalog.SessionContext context, TableIdentifier identifier); + + /** + * Rename a view. + * + * @param from identifier of the view to rename + * @param to new view identifier + * @throws NoSuchViewException if the "from" view does not exist + * @throws AlreadyExistsException if the "to" view already exists + */ + void renameView(SessionCatalog.SessionContext context, TableIdentifier from, TableIdentifier to); + + /** + * Invalidate cached view metadata from current catalog. + * + * <p>If the view is already loaded or cached, drop cached data. If the view does not exist or is + * not cached, do nothing. + * + * @param identifier a view identifier + */ + default void invalidateView(SessionCatalog.SessionContext context, TableIdentifier identifier) {} + + /** + * Initialize a view catalog given a custom name and a map of catalog properties. + * + * <p>A custom view catalog implementation must have a no-arg constructor. A compute engine like + * Spark or Flink will first initialize the catalog without any arguments, and then call this + * method to complete catalog initialization with properties passed into the engine. + * + * @param name a custom name for the catalog + * @param properties catalog properties + */ + default void initialize(String name, Map<String, String> properties) {} Review Comment: There's no need for a default here since this is a new interface. It's fine for `invalidateView` because most catalogs won't cache, but `initialize` is something we want implemented. This should also avoid issues with conflicting defaults. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org