amogh-jahagirdar commented on code in PR #6861:
URL: https://github.com/apache/iceberg/pull/6861#discussion_r1113714107


##########
api/src/main/java/org/apache/iceberg/view/ViewVersion.java:
##########
@@ -58,4 +61,25 @@ public interface ViewVersion {
    * @return the list of view representations
    */
   List<ViewRepresentation> representations();
+
+  /**
+   * Return the operation which produced the view version
+   *
+   * @return Return the operation which produced the view version
+   */
+  Operation operation();
+
+  enum Operation {
+    CREATE,
+    REPLACE;
+
+    public static Operation fromName(String operation) {
+      Preconditions.checkArgument(operation != null, "Invalid operation: 
null");
+      try {
+        return Operation.valueOf(operation.toUpperCase(Locale.ENGLISH));
+      } catch (IllegalArgumentException e) {
+        throw new IllegalArgumentException(String.format("Invalid operation: 
%s", operation), e);
+      }

Review Comment:
   @rdblue let me know if you have any concerns on doing a strict validation on 
the operation type. This is where we diverge from the model that Table snapshot 
takes. 
   
   This is in the view spec, and I think it makes sense as a format for views 
for Iceberg to rigorously enforce what are the acceptable operations to produce 
a version. 
   
   Was digging through the history for why we don't validate the operations 
when parsing a snapshot, and found this 
https://github.com/apache/iceberg/pull/74/files#r257350134 . Let me know if you 
have any concerns on forward compatibility with this approach? 



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