rdblue commented on code in PR #4925:
URL: https://github.com/apache/iceberg/pull/4925#discussion_r990854697


##########
api/src/main/java/org/apache/iceberg/catalog/ViewCatalog.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.NoSuchViewException;
+import org.apache.iceberg.exceptions.NotFoundException;
+import org.apache.iceberg.view.View;
+import org.apache.iceberg.view.ViewRepresentation;
+
+/** A Catalog API for view create, drop, and load operations. */
+public interface ViewCatalog {
+
+  /**
+   * 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 NotFoundException if the namespace is not found
+   */
+  List<TableIdentifier> listViews(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(TableIdentifier identifier);
+
+  /**
+   * Check whether view exists.
+   *
+   * @param identifier a view identifier
+   * @return true if the table exists, false otherwise
+   */
+  default boolean viewExists(TableIdentifier identifier) {
+    try {
+      loadView(identifier);
+      return true;
+    } catch (NoSuchViewException e) {
+      return false;
+    }
+  }
+
+  /**
+   * Create a view.
+   *
+   * @param identifier a view identifier
+   * @param representations a list of view representations
+   * @param properties a string map of view properties
+   */
+  View createView(
+      TableIdentifier identifier,
+      List<ViewRepresentation> representations,
+      Map<String, String> properties);
+
+  /**
+   * Replace a view.
+   *
+   * @param identifier a view identifier
+   * @param representations a list of view representations
+   * @param properties a string map of view properties
+   */
+  View replaceView(
+      TableIdentifier identifier,
+      List<ViewRepresentation> representations,
+      Map<String, String> properties);
+
+  /**
+   * Drop a view and delete all metadata files.
+   *
+   * @param identifier a view identifier
+   * @return true if the view was dropped, false if the view did not exist
+   */
+  default boolean dropView(TableIdentifier identifier) {
+    return dropView(identifier, true /* drop metadata files */);
+  }
+
+  /**
+   * Drop a view; optionally delete metadata files.
+   *
+   * <p>If purge is set to true the implementation should delete all metadata 
files.
+   *
+   * @param identifier a view identifier
+   * @param purge if true, delete all metadata files in the view
+   * @return true if the view was dropped, false if the view did not exist
+   */
+  boolean dropView(TableIdentifier identifier, boolean purge);

Review Comment:
   Why is there a `purge` option here? Is there value to requiring this?
   
   The `purge` option for tables is not very valuable and is in a lot of cases 
misunderstood. The problem is that it confuses two needs: "clean up resources" 
and "do this immediately". Cleaning up resources (i.e., metadata and data 
files) should be done on a schedule determined by the catalog and 
administrators. That way undrop can be supported. Doing something immediately 
should be used when it is urgent that the underlying resources are removed for 
some other reason, like needing to completely remove PII that has leaked.
   
   In the view case, I see no need for `purge` because I doubt there is a case 
where deleting a view's description or representation must be done immediately.



-- 
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

Reply via email to