jason810496 commented on code in PR #1828:
URL: https://github.com/apache/iceberg-python/pull/1828#discussion_r2008722936


##########
pyiceberg/cli/console.py:
##########
@@ -86,31 +91,48 @@ def run(
         ctx.obj["output"] = JsonOutput(verbose=verbose)
 
     try:
-        ctx.obj["catalog"] = load_catalog(catalog, **properties)
+        ctx.obj["first_level_catalog"] = catalog
+        ctx.obj["second_level_catalog"] = None
+        ctx.obj["properties"] = properties
+        
     except Exception as e:
         ctx.obj["output"].exception(e)
         ctx.exit(1)
 
+
+def _load_the_catalog_with_first_level_catalog(ctx: Context) -> None:
+    if ctx.obj["first_level_catalog"] is None and 
ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = load_catalog(None, **ctx.obj["properties"])
+    elif ctx.obj["first_level_catalog"] is not None and 
ctx.obj["second_level_catalog"] is None:
+        ctx.obj["catalog"] = 
load_catalog(ctx.obj["first_level_catalog"],**ctx.obj["properties"])
+    else:
+        ctx.obj["catalog"] = 
load_catalog(ctx.obj["second_level_catalog"],**ctx.obj["properties"])

Review Comment:
   We can refactor as:
   ```suggestion
       catalog_option = ctx.obj.get("first_level_catalog",None) or 
ctx.obj.get("second_level_catalog",None)
       ctx.obj["catalog"] = load_catalog(catalog_option,**ctx.obj["properties"])
   ```



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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to