rdblue commented on code in PR #5488:
URL: https://github.com/apache/iceberg/pull/5488#discussion_r942651363


##########
python/pyiceberg/utils/config.py:
##########
@@ -0,0 +1,125 @@
+# 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.
+import logging
+import os
+import site
+import sys
+from typing import Any, List
+
+import yaml
+
+from pyiceberg.typedef import EMPTY_DICT, Configuration, FrozenDict
+
+PYICEBERG = "pyiceberg__"
+CATALOG = "catalog"
+
+PATHS = [
+    f"{os.environ.get('ICEBERG_ROOT_CONFIG', 
'/etc/pyiceberg').rstrip('/')}/pyiceberg",
+    *[f"{prefix}/etc/pyiceberg" for prefix in site.PREFIXES],
+    f"{sys.prefix}/etc/pyiceberg",
+    "~/config/pyiceberg",
+]
+
+
+def merge_dicts(lhs: Configuration, rhs: Configuration) -> Configuration:
+    """merges left-hand side into the right-hand side"""
+    for lhs_key, lhs_value in lhs.items():
+        if lhs_key in rhs:
+            rhs_value = rhs[lhs_key]
+            if isinstance(lhs_value, dict) and isinstance(rhs_value, dict):
+                lhs[lhs_key] = merge_dicts(lhs_value, rhs_value)
+            elif lhs_value != lhs_value:

Review Comment:
   Did you intend to compare left with right? This compares left with itself 
and will never trigger.
   
   Also, the doc says this merges the left into the right, but this is actually 
merging the right into the left. The left is modified and the right takes 
precedence. I generally prefer to create new dicts rather than modifying 
incoming values.
   
   We should also decide on precedence. There are existing patterns for both 
left and right precedence. If we think of this like a "coalesce" operation that 
takes the first non-null, then the left value should be used. If we think of it 
like "dict.update" then the right value should be used. I assumed the first, 
but it looks like you're intending to use the second. Let's just make sure it 
is clear which one we are going with.



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