dimas-b commented on code in PR #1417:
URL: https://github.com/apache/polaris/pull/1417#discussion_r2080622368


##########
service/common/src/main/java/org/apache/polaris/service/config/ReservedProperties.java:
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.config;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import org.apache.iceberg.MetadataUpdate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Used to track entity properties reserved for use by the catalog. These 
properties may not be
+ * overridden by the end user.
+ */
+public interface ReservedProperties {
+  Logger LOGGER = LoggerFactory.getLogger(ReservedProperties.class);
+
+  /**
+   * A list of prefixes that are considered reserved. Any property starting 
with one of these
+   * prefixes is a reserved property.
+   */
+  List<String> reservedPrefixes();
+
+  /** If true, attempts to modify a reserved property should throw an 
exception. */
+  default boolean shouldThrow() {
+    return true;
+  }
+
+  /**
+   * Removes reserved properties from a planned change to an entity. If 
`shouldThrow`returns true,
+   * this will throw an IllegalArgumentException.
+   *
+   * @param existingProperties The properties currently present for an entity
+   * @param updateProperties The properties present in an update to an entity
+   * @return The keys from the new key list which are not reserved properties
+   */
+  default Map<String, String> removeReservedPropertiesFromUpdate(
+      Map<String, String> existingProperties, Map<String, String> 
updateProperties)
+      throws IllegalArgumentException {
+    Map<String, String> updatePropertiesWithoutReservedProperties =
+        removeReservedProperties(updateProperties);
+    for (var entry : updateProperties.entrySet()) {
+      // If a key was removed from the update, we substitute in the existing 
value as to not remove
+      // it
+      if 
(!updatePropertiesWithoutReservedProperties.containsKey(entry.getKey())) {

Review Comment:
   ok



-- 
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...@polaris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to