huaxingao commented on code in PR #14984:
URL: https://github.com/apache/iceberg/pull/14984#discussion_r3694537924


##########
spark/v4.2/spark/src/main/java/org/apache/iceberg/spark/SparkSessionCatalog.java:
##########
@@ -457,63 +517,47 @@ public View loadView(Identifier ident) throws 
NoSuchViewException {
   }
 
   @Override
-  public View createView(ViewInfo viewInfo)
+  public View createView(Identifier ident, View view)
       throws ViewAlreadyExistsException, NoSuchNamespaceException {
-    if (viewInfo == null) {
+    if (view == null) {
       return null;
     }
 
+    View normalizedView = normalizeViewCurrentCatalog(catalogName, view);
     if (null != asViewCatalog) {
-      return asViewCatalog.createView(viewInfo);
+      return asViewCatalog.createView(ident, normalizedView);
     } else if (isViewCatalog()) {
-      return getSessionCatalog().createView(viewInfo);
+      return getSessionCatalog().createView(ident, normalizedView);
     }
 
     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);
+  public View replaceView(Identifier ident, View view) throws 
NoSuchViewException {
+    View normalizedView = normalizeViewCurrentCatalog(catalogName, view);
+    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {
+      return asViewCatalog.replaceView(ident, normalizedView);
+    } else if (isViewCatalog() && getSessionCatalog().viewExists(ident)) {
+      return getSessionCatalog().replaceView(ident, normalizedView);
     }
 
-    throw new UnsupportedOperationException(
-        "Replacing a view is not supported by catalog: " + catalogName);
+    throw new NoSuchViewException(ident);
   }
 
   @Override
-  public View alterView(Identifier ident, ViewChange... changes)
-      throws NoSuchViewException, IllegalArgumentException {
-    if (null != asViewCatalog && asViewCatalog.viewExists(ident)) {
-      return asViewCatalog.alterView(ident, changes);
+  public View createOrReplaceView(Identifier ident, View view)
+      throws ViewAlreadyExistsException, NoSuchNamespaceException {
+    View normalizedView = normalizeViewCurrentCatalog(catalogName, view);
+    if (null != asViewCatalog) {
+      return asViewCatalog.createOrReplaceView(ident, normalizedView);
     } else if (isViewCatalog()) {
-      return getSessionCatalog().alterView(ident, changes);
+      return getSessionCatalog().createOrReplaceView(ident, normalizedView);
     }
 
     throw new UnsupportedOperationException(
-        "Altering a view is not supported by catalog: " + catalogName);
+        "Replacing a view is not supported by catalog: " + catalogName);

Review Comment:
   Should be `"Creating or replacing a view is not supported by catalog: "`



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to