nastra commented on code in PR #11388:
URL: https://github.com/apache/iceberg/pull/11388#discussion_r1868056254


##########
spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java:
##########
@@ -397,4 +412,155 @@ public UnboundFunction loadFunction(Identifier ident) 
throws NoSuchFunctionExcep
       return getSessionCatalog().loadFunction(ident);
     }
   }
+
+  @Override
+  public Identifier[] listViews(String... namespace) {
+    try {
+      if (null != asViewCatalog) {
+        return asViewCatalog.listViews(namespace);
+      } else if (isViewCatalog()) {
+        getSessionCatalog().listViews(namespace);
+      }
+    } catch (NoSuchNamespaceException e) {
+      throw new RuntimeException(e);
+    }
+
+    return new Identifier[0];
+  }
+
+  @Override
+  public View loadView(Identifier ident) throws NoSuchViewException {
+    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {
+      return asViewCatalog.loadView(ident);
+    } else if (isViewCatalog() && getSessionCatalog().viewExists(ident)) {
+      return getSessionCatalog().loadView(ident);
+    }
+
+    throw new NoSuchViewException(ident);
+  }
+
+  @Override
+  public View createView(
+      Identifier ident,
+      String sql,
+      String currentCatalog,
+      String[] currentNamespace,
+      StructType schema,
+      String[] queryColumnNames,
+      String[] columnAliases,
+      String[] columnComments,
+      Map<String, String> properties)
+      throws ViewAlreadyExistsException, NoSuchNamespaceException {
+    if (null != asViewCatalog) {
+      return asViewCatalog.createView(
+          ident,
+          sql,
+          currentCatalog,
+          currentNamespace,
+          schema,
+          queryColumnNames,
+          columnAliases,
+          columnComments,
+          properties);
+    } else if (isViewCatalog()) {
+      return getSessionCatalog()
+          .createView(
+              ident,
+              sql,
+              currentCatalog,
+              currentNamespace,
+              schema,
+              queryColumnNames,
+              columnAliases,
+              columnComments,
+              properties);
+    }
+
+    throw new UnsupportedOperationException(
+        "Creating a view is not supported by catalog: " + catalogName);
+  }
+
+  @Override
+  public View replaceView(
+      Identifier ident,
+      String sql,
+      String currentCatalog,
+      String[] currentNamespace,
+      StructType schema,
+      String[] queryColumnNames,
+      String[] columnAliases,
+      String[] columnComments,
+      Map<String, String> properties)
+      throws NoSuchNamespaceException, NoSuchViewException {
+    if (asViewCatalog instanceof SupportsReplaceView) {
+      return ((SupportsReplaceView) asViewCatalog)
+          .replaceView(
+              ident,
+              sql,
+              currentCatalog,
+              currentNamespace,
+              schema,
+              queryColumnNames,
+              columnAliases,
+              columnComments,
+              properties);
+    } else if (isViewCatalog()) {
+      try {
+        getSessionCatalog().dropView(ident);

Review Comment:
   this was mostly following Spark's example in 
https://github.com/apache/spark/blob/6cd13344bffd411289ec20170ae2da2035bb2859/sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/ViewCatalog.java#L124-L152
 but I agree that we maybe don't want to do this non-atomically. If needed, we 
can always add that back later



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