danielcweeks commented on a change in pull request #4220:
URL: https://github.com/apache/iceberg/pull/4220#discussion_r814387579



##########
File path: core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java
##########
@@ -440,36 +389,39 @@ public boolean setProperties(Namespace namespace, 
Map<String, String> properties
       throw new NoSuchNamespaceException("Namespace does not exist: %s", 
namespace);
     }
 
-    if (properties == null || properties.isEmpty()) {
-      throw new IllegalArgumentException("Cannot set properties to a namespace 
with null or empty properties");
+    Preconditions.checkNotNull(properties, "Invalid properties to set: null");
+
+    if (properties.isEmpty()) {
+      return false;
     }
 
-    Map<String, String> namespaceProperties = fetchProperties(namespace);
-    Map<String, String> propertiesToInsert = Maps.newHashMap();
-    Map<String, String> propertiesToUpdate = Maps.newHashMap();
+    
Preconditions.checkArgument(!properties.containsKey(NAMESPACE_EXISTS_PROPERTY),
+        "Cannot set reserved property: %s", NAMESPACE_EXISTS_PROPERTY);
+
+    Map<String, String> startingProperties = fetchProperties(namespace);
+    Map<String, String> inserts = Maps.newHashMap();
+    Map<String, String> updates = Maps.newHashMap();
 
     for (String key : properties.keySet()) {
       String value = properties.get(key);
-      if (namespaceProperties.containsKey(key)) {
-        if (!namespaceProperties.get(key).equals(value)) {
-          propertiesToUpdate.put(key, value);
-        }
+      if (startingProperties.containsKey(key)) {
+        updates.put(key, value);
       } else {
-        propertiesToInsert.put(key, value);
+        inserts.put(key, value);
       }
     }
 
-    boolean insertedProperties = true;
-    if (!propertiesToInsert.isEmpty()) {
-      insertedProperties = insertProperties(namespace, propertiesToInsert);
+    boolean hadInserts = false;
+    if (!inserts.isEmpty()) {
+      hadInserts = insertProperties(namespace, inserts);
     }
 
-    boolean updatedProperties = true;
-    if (!propertiesToUpdate.isEmpty()) {
-      updatedProperties = updateProperties(namespace, propertiesToUpdate);
+    boolean hadUpdates = false;
+    if (!updates.isEmpty()) {
+      hadUpdates = updateProperties(namespace, updates);
     }
 
-    return (insertedProperties && updatedProperties);
+    return hadInserts || hadUpdates;

Review comment:
       This may be out of scope for this PR, but these operations don't appear 
to be atomic.




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