gaborkaszab commented on code in PR #15903:
URL: https://github.com/apache/iceberg/pull/15903#discussion_r3078507776


##########
core/src/main/java/org/apache/iceberg/rest/RESTCatalogProperties.java:
##########
@@ -69,25 +66,5 @@ public enum SnapshotMode {
   public enum ScanPlanningMode {
     CLIENT,
     SERVER;
-
-    public String modeName() {
-      return name().toLowerCase(Locale.ROOT);
-    }
-
-    public static ScanPlanningMode fromString(String mode) {
-      for (ScanPlanningMode planningMode : values()) {
-        if (planningMode.modeName().equalsIgnoreCase(mode)) {
-          return planningMode;
-        }
-      }
-
-      throw new IllegalArgumentException(
-          String.format(
-              "Invalid scan planning mode: %s. Valid values are: %s",
-              mode,
-              Arrays.stream(values())
-                  .map(ScanPlanningMode::modeName)
-                  .collect(Collectors.joining(", "))));
-    }

Review Comment:
   Thanks for spotting this! My initial intention was to rather start a 
conversation on this, but I forgot to write the comment.
   1) In general I don't think we print the available values when we can't 
initialize an enum. These values are [in the 
docs](https://github.com/apache/iceberg/pull/15871), seems an overkill to also 
return here.
   2) Instead of having a for loop of values, we can just simply use the 
`valueOf` of the enum. This simplifies the `fromString` implementation.
   
   I went back to use the `fromString` function because it can hide some 
details, like calling uppercase, and this way we can have a custom error 
message instead of the one from the enum. I felt printing the available values 
is an overkill, and also went for the simplification in 2)
   Taking a step back, the changes on the enum seems orthogonal to the original 
intent of the PR, so I can split that into a separate one (and also tackle the 
same for SnapshotMode).
   
   WDYT @singhpk234 



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