talatuyarer commented on code in PR #17874:
URL: https://github.com/apache/iceberg/pull/17874#discussion_r4078760838


##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/FlinkCatalog.java:
##########
@@ -641,6 +662,56 @@ private void createIcebergView(
     }
   }
 
+  private void alterIcebergView(
+      ObjectPath tablePath, ResolvedCatalogView newView, boolean 
ignoreIfNotExists)
+      throws TableNotExistException, CatalogException {
+    View view;
+    try {
+      view = asViewCatalog.loadView(toIdentifier(tablePath));
+    } catch (NoSuchViewException e) {
+      if (!ignoreIfNotExists) {
+        throw new TableNotExistException(getName(), tablePath, e);
+      }
+
+      return;
+    }
+
+    SQLViewRepresentation currentRepresentation = view.sqlFor(FLINK_DIALECT);
+    if (currentRepresentation == null
+        || !newView.getExpandedQuery().equals(currentRepresentation.sql())) {
+      // a new query becomes a new view version, stored the same way 
createIcebergView stores
+      // one: the expanded query, with the defaults recording the resolution 
context
+      view.replaceVersion()

Review Comment:
   Good point. I switched the query-change path to ViewBuilder.replace(), which 
commits the new version and the property updates in a single metadata commit, 
so there is no partial state anymore. Property-only changes were already one 
updateProperties commit. On conflict it fails with CommitFailedException like 
other view replaces, no retry, it is same as Spark's replace path.



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